Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to display multiple posts from different categories to represent featured on my blog. What I did was <?php query_posts("showposts=2&cat=3"); $i = 1; ?> or

<?php query_posts("showposts=2&cat=1,3"); $i = 1; ?>

Both won't work. Any clues?

share|improve this question

closed as not a real question by toscho Jul 9 '12 at 21:42

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

You need a complete query loop that won't conflict with other loops:

<?php $my_query = new WP_Query('showposts=2&cat=1,3'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">

<?php the_title(); ?></a>

<?php the_content(); ?> //optional, can also be the_excerpt

<?php endwhile; ?>

http://codex.wordpress.org/Class_Reference/WP_Query

share|improve this answer
It won work because it pulls the most recent posts that match the criteria, not "a" post from each category. – Freeme Aug 9 '11 at 19:20
1  
Please update your question with the entire loop code and try to explain exactly what you need. – Wyck Aug 9 '11 at 19:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.