I would like to generate a list of posts if they exist in two categories.
Is it possible to do something like this?
<?php
$posts = get_posts('category=1&category=2');
foreach($posts as $post) :
setup_postdata($post);
?>
I would like to generate a list of posts if they exist in two categories.
Is it possible to do something like this?
<?php
$posts = get_posts('category=1&category=2');
foreach($posts as $post) :
setup_postdata($post);
?>
Any answer on this one yet? I'm looking to do the same thing.
(the suggested code above does not work)
Your answer:
http://codex.wordpress.org/Template_Tags/query_posts
http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters
Note that if you're planning to use this in a template which will have one or more other post loops (including The Loop), creating a new WP_Query class would be better suited for it:
This topic has been closed to new replies.