wordpress get random posts from category

In wordpress widget or on homepage, In wordpress get random posts from category. Here in wordpress tutorial we have given some nice tricks and tips for wordpress developers. There are many ways to achieve this. I can recommend to use Page Builder Plugin and use smart posts widget plugin.

wordpress get random posts from category

Above plugin will not add any database table to your wordpress website. We prefer to use the above plugin. Using smart posts widget plugin, you can show random post with simple setting or configuration.

Still you want to show random post by using code than use following code.

 

$query_params="post_type=post&showposts=10&cat=12&orderby=rand&order=DESC";
$smart_posts = new WP_Query($query_params);

while ( $smart_posts->have_posts() )
{
$smart_posts->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<?php the_post_thumbnail(); ?>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</a>
<?php the_excerpt(); ?> 

<?
}
wp_reset_postdata();


 

 

Features of Plugin which shows every types of posts.

Smart Posts Widget

wordpress get random posts from category
wordpress get random posts from category

 

Smart Posts Widget – is designed to show your posts as you want without any programming knowledge. display all type of post types from a certain post type or post category or post tags.

There are many options for user to filter or order posts. You can able to select many options to choose your posts.

Smart Posts Widgets developed to provide very easy to user for displaying all types of posts within your widget areas.

widget is compatible with Page Builder. You can create beautiful page layouts and show posts as per your choice.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.