WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Category Requirement in Loop (2 posts)

  1. Lara Chelak
    Member
    Posted 5 years ago #

    Hi!

    I'd like to make a requirement for multiple categories for the select posts to be displayed. Here's the part of my loop I need to adjust.

    <?php query_posts(array('category_name' => uncategorized, 'showposts' => 2)); if (have_posts()) : while (have_posts()) : the_post(); ?>

    I need posts with both the uncategorized and nightlife categories checked.

    How can I best do this?

    Much thanks,
    Lara

  2. stvwlf
    Member
    Posted 5 years ago #

    from http://codex.wordpress.org/Template_Tags/query_posts

    Display posts that are in multiple categories. This shows posts that are in both categories 2 and 6:

    query_posts(array('category__and' => array(2,6)));

Topic Closed

This topic has been closed to new replies.

About this Topic