• Hi!

    I’m making a page template where I use a custom field to set a post as featured at the top of the page (in this case meta_key=getactive). I want the rest of the posts in that category to appear underneath, excluding the post I just featured.

    I looked everywhere online and in the codex, but there doesn’t seem to be a way to exclude posts with a meta_key value when calling posts from a category using query_posts.

    Here’s the code I used to call the feature post:

    <?php query_posts(‘meta_key=getactive&meta_value=yes’); ?>

    And here’s what I’m using to call the category, where I’d like to exclude the post I just called:

    <?php query_posts(‘category_name=Get Active&showposts=10’); ?>

    Anyone know how to do this?

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • perhaps:

    <?php $featured = new WP_Query('meta_key=getactive&meta_value=yes&showposts=1');
    if($featured->have_posts()) : while($featured->have_posts()) : $featured->the_post();
    $nocopy = $post->ID;?>
    
    layout here
    
    <?php endwhile; endif; ?>
    
    <?php $get_active_cat = ('category_name=get-active&showposts=10');
    if($get_active_cat->have_posts()) : while($get_active_cat->have_posts()) : $get_active_cat->the_post;
    if($post->ID == $nocopy) continue; ?>
    
    layout here
    
    <?php endwhile; endif; ?>

    ?

    I too am looking to this, but unfortunately, I can’t work out what’s going on in doodlebee’s code. If you’re still following this topic, can you pop back please?

    For what it’s worth I have a post over here and I think it’s in the wrong section. Should be in themes and templates

    http://wordpress.org/support/topic/403089

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to exclude meta_key from query_posts?’ is closed to new replies.