• Apr
  • 19
  • 2012
blog-image

We found many people asking that, “How to show posts of a particular category in wordpress?”, We can’t stop our self to write the code for it, so that the wordpress users can breathe easily.

You can use the wordpress’s default functions to display the desired output. Here we are using get_posts() function of wordpress. The name itself suggests that it is used to get the posts. 🙂

Here is the code to list down the posts of a particular category :

global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => CATEGORY_ID );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>

You can also use the different combinations of below arguments to get your desired output. If you don’t want to do then we are here to do it for you. 🙂

'numberposts' => 5,
'offset' => 0,
'category' => ,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ,
'exclude' => ,
'meta_key' => ,
'meta_value' => ,
'post_type' => 'post',
'post_mime_type' => ,
'post_parent' => ,
'post_status' => 'publish' ); ?>

Don’t forget to replace the CATEGORY_ID with your categorie’s id whose posts you want to list down.

You can add your own html format for listing the posts.

Its pretty Simple !!! 🙂

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Popular Blogs

recent-blog-image

Today’s restaurant business is booming and most of the owners…

recent-blog-image

This question is most searched question in google. It is…

recent-blog-image

When you are using WPML in wordpress at that time…

recent-blog-image

Method for linking pages that aren't in a Site Menu…

recent-blog-image

Manier times we come across requirement like fetching/getting content from…

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.