Home Forums ACF PRO Hide post with true/flase


Hide post with true/flase

  • I’m want to hide some post of the home page. So i’ve setup and post array to show post that are not equal to 1. Butit doesn’t seem to be playing ball.

    $args = array(
    ‘meta_query’ => array(
    ‘key’ => ‘hideme’,
    ‘value’ => ‘1’,
    ‘compare’ => ‘!=’


    I have var dumped the field and it’s coming out with 1NULL or NULL. 1NULL being the post i’d like to hide

  • Hi @beeblu

    Could you please try this code:

    $args = array(
        'post_type'			=> 'post',
        'posts_per_page'	=> -1,
        'meta_key'			=> 'hideme',
        'meta_value'		=> '1',

    I hope this helps.

  • Hi James, Thanks but this shows the post I want to do the opposite but if set the value to 0 or null I get nothing as the field doesn’t have anything set in the field. I though the best way to fix this would be show everything that not a 1 with a !=. Do you think I’m on the right track?

  • Hi @beeblu

    I’m sorry I got it wrong. For something like that, you need to use the ‘meta_compare’ option. It should be like this:

        'post_type'        => 'post',
        'posts_per_page'   => -1,
        'meta_key'         => 'hideme',
        'meta_value'       => '1',
        'meta_compare'     => '!='

    This page should give you more idea about it:

    Hope this helps!

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Hide post with true/flase’ is closed to new replies.