Support » Fixing WordPress » Filtering categories within a loop/query_posts

  • coyacreative

    (@coyacreative)


    <?php query_posts('category_name=people&posts_per_page=50'); ?>
    <?php $acs->query_posts(array('group_name' => 'People')); ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <li><a class="popup" href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, 'homepage_thumbnail', true); ?>" /></a></li>
    <?php endwhile; ?>

    Is there a way for me to call the category ‘people’ but have it exclude all posts that are in another category as well?

    Post 1 – People
    Post 2 – People
    Post 3 – People, Other
    Post 4 – People
    ….

    I am looking to query all people, but ignore posts that are in the ‘other’ category.

    Thanks for any help in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Forum Moderator

    <?php
    $args = array(
    'category_name' =? 'people',
    'posts_per_page' => 50,
    'category__not_in' => array( x )
    );?>

    where x is the id of your Other category.

    coyacreative

    (@coyacreative)

    <?php $acs->query_posts(array('group_name' => 'People')); ?>

    Thanks, esmi. But I just realized the plugin Advance Custom Sort for posts is causing this to not work.

    I am using the sort list for grid view – but am needing the same ‘group’ on the homepage, but to manually remove a few posts.

    I have contacted the plugin developer – I hope it’s possible.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filtering categories within a loop/query_posts’ is closed to new replies.