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(); ?>"> <?php the_post_thumbnail(); ?> </a> <?php the_excerpt(); ?> <? } wp_reset_postdata();
Features of Plugin which shows every types of posts.
Smart Posts Widget
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.