Support

Account

Home Forums ACF PRO Filter my $wp_query with meta_key

Solved

Filter my $wp_query with meta_key

  • Hi guys,

    I would like to filter the main $wp_query to exclude posts with a specific meta_key value. But my $wp_query return nothing when I add these parameters where it works smoothly without ‘meta_key’ and ‘meta_value’.

    Any advise on how I could fix that?

    Thanks in advance for your time.

    J.

    <?php 
    global $wp_query; 
    $args = array_merge( $wp_query->query_vars, array( 'posts_per_page' => 15,<strong>'meta_key' => 'collaborator', 'meta_value' => 'yes' </strong>) ); 
    query_posts( $args ); 
    ?>
  • 'meta_query' => array( array('key' => 'collaborator','value' => 'no','compare' => '='))

    Stupid me ! I solved it like that…

  • Thanks for posting your solution!

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

The topic ‘Filter my $wp_query with meta_key’ is closed to new replies.