Want to showcase random posts in WordPress to help users discover more of your content? As experienced WordPress users with years of site optimization under our belt, we've found this technique boosts engagement and page views significantly. In this guide, we'll walk you through two straightforward methods to display random posts effortlessly.

WordPress displays posts in reverse chronological order by default—newest first. While great for fresh content, it buries your older gems, limiting their visibility.
Internal linking in new posts helps, driving traffic and SEO benefits. But adding a random posts widget to your sidebar takes it further, surfacing hidden content naturally.
Let's dive in.
Subscribe to WPBeginner for more tips. Prefer reading? Scroll down for the step-by-step text guide.
This beginner-friendly approach requires no coding. Install and activate the Advanced Random Posts Widget plugin. (See our step-by-step plugin installation guide.)
Head to Appearance » Widgets. Drag the new "Random Posts" widget to your sidebar. Refer to our widgets guide if needed.
Default settings work well for most sites—hit Save.

This robust plugin offers customization: filter by post type, categories, tags; add excerpts, thumbnails; even exclude posts or inject custom HTML/CSS.
Save changes and view your site—the widget is live!

For developers, add this to your theme's functions.php or a site-specific plugin:
function wpb_rand_posts() {
$string = '';
$args = array(
'post_type' => 'post',
'orderby' => 'rand',
'posts_per_page' => 5,
);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) {
$string .= '<ul>';
while ($the_query->have_posts()) {
$the_query->the_post();
$string .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
$string .= '</ul>';
wp_reset_postdata();
} else {
$string .= '<p>No posts found.</p>';
}
return $string;
}
add_shortcode('wpb-random-posts', 'wpb_rand_posts');
add_filter('widget_text', 'do_shortcode');This creates a shortcode [wpb-random-posts] for posts, pages, or text widgets, pulling 5 random posts with links.

That's it! These methods have helped countless sites revive old content. For more, check our 12 WordPress Sidebar Tricks to Increase Page Views.
Subscribe to our YouTube channel, follow on Twitter and Facebook for updates.