Home > database >  Show post if true/false is no ACF
Show post if true/false is no ACF

Time:06-08

How to display only posts, what have field "nezobrazovat" as false?

This is my code:

        $args = array(
            'posts_per_page' => 3,
            'post_type' => 'mycustompost',
            'key'=> 'nezobrazovat',
            'value'=>'no',
        );

This doesnt work, all first 3 posts are displayed

CodePudding user response:

From the acf docs the value is 1 or 0

$posts = get_posts( array(
    'meta_query' => array(
        array(
            'key'   => 'show_in_sidebar',
            'value' => '1',
        )
    )
) );

https://www.advancedcustomfields.com/resources/true-false/

  • Related