How Can I Use WP_Query to Display Posts from Only ONE Category?
-
Hey Guys,
I have searched the internet for the last hour trying to look for a solution to my problem, but I either cannot find it, or am looking for the wrong thing.
I am using…
<?php $recent = new WP_Query(“showposts=3”); while($recent->have_posts()) : $recent->the_post();?>
…to display some recent posts in my sidebar. It works really well. So I want to use it to display 3 posts from a specific category, on my blogs homepage.
I have the working code on my home page, its displaying the correct number of posts, but I cannot work out how to make it only show posts from a specific category. In this case, I want only posts from the ‘Gallery’ category, to show up. That cat number is 10.
What do I have to add to the code to make it only show posts from that category please?
- The topic ‘How Can I Use WP_Query to Display Posts from Only ONE Category?’ is closed to new replies.