WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do I show posts from multiple categories using WP_Query? (3 posts)

  1. nextlimits
    Member
    Posted 4 years ago #

    Here I'm using one category name to list posts from it. How can I list posts from 2 categories in the same page - what are the arguments for the query ?

    <?php $recentProjects = new WP_Query();
    $recentProjects->query('category_name=proiecte'); ?>
    <?php while ($recentProjects->have_posts()) : recentProjects->the_post(); ?>

    Thank you

  2. vtxyzzy
    Member
    Posted 4 years ago #

    See the Codex on query parameters.

    $args = array(
       'category__in' => array(2,16)
    }
    $recentProjects->query($args);
  3. nextlimits
    Member
    Posted 4 years ago #

    Thanks - it worked!

Topic Closed

This topic has been closed to new replies.

About this Topic