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 !!! 🙂
Do You Like This Article? Get It In Your Inbox Daily.
Among the many digital tools that are being used with increasing frequency, the one that has the greatest...
Having a Best Website like opening a door and inviting…
In this internet era, the business website is the most…
The Live chat is the common thing now days, if…
- Artificial Intelligence
- Augmented Reality
- Business Development
- Cloud Server
- Digital Marketing
- Featured Post
- Guru Technolabs
- Mobile App Development
- Real Estate
- Social Media
- Web Development
- Web Scraping
- Website Design
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.