I am trying to display WordPress posts of only one category called news on my page… However I can’t seem to make it work, it still displays all posts. Any idea what I am doing wrong? The code is
<?php
$postslist = get_posts('category=news&numberposts=10000&order=DESC&orderby=date');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<li>
<?php echo get_the_post_thumbnail( $page->ID, 'thumbnail' ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<br><span class="caption"><?php the_time(get_option('date_format')) ?></span>
</li>
<?php endforeach; ?>
Thanks
You try to get the category by name.
But your code is not correct for this method.
Try this:
Or use the category ID to get your results:
You can read more about
get_posts
here:http://codex.wordpress.org/Template_Tags/get_posts