I’m trying to only display posts from a certain category in a widget. I’ve tried it in a few different ways but it is still showing posts from all categories. Here’s my code at the moment:
$posts = get_posts(array ('category'=>6, 'numberposts'=>$number, 'order'=>'DESC', 'orderby'=>'date'));
foreach ($posts as $post){
setup_postdata($post);....
Thanks.
Did you try the example given in the codex?
This a modified version that should suit your needs. Are you also certain that this category exists?
Edit:
I guess you got 2 loops and maybe one before. Try to use
wp_reset_query()
before orrewind_posts()
.