I am developing one project and in this project i have to display all the posts related to particular category name.
I have searched a lot but i haven’t got any idea to implement this.
How can i do this so that i can display all the posts from particular category/term
Just use
WP_Query()
to generate your custom query, using the category parameters.Assuming you know (or know how to get) the ID of the specific category, as
$catid
:Note: you could also pass the category slug to the query, via
category_name
, instead ofcat
.Now, just output your loop:
That would depend on when and how exactly you want to use it – but generally speaking you can either use a custom query , or simply use
if you want to learn about custom query : http://codex.wordpress.org/Custom_Queries
Below code will fetch post title from particular category name.
WP_Query
‘stax_query
is, far and away, going to be the most flexible way to implement this. If you make the question a bit more specific, I should be able to crank out some sample code for you to get you going.You can use a plugin (WordPress Category Posts) for that.
WordPress Category Posts is a plugin for WordPress that creates a linked list of the posts in a specific category.
Use the following code wherever you want to list the posts for a category:
Many thanks.