First thing you need to do is install and activate the Advanced Random Posts Widget plugin.
Upon activation, you need to visit Appearance » Widgets page. You will notice a new widget labeled ‘Random Posts’ under the list of available widget.
You need to add this widget to a sidebar. Now, you will be able to see the widget settings. The default options will work for most websites, you can just click on the save button.
Advanced Random Posts Widget is a powerful plugin with tons of customization options. You can select different post types, show excerpt, show thumbnail, and skip posts you don’t want to show, or displays posts from specific categories or tags.
For more experienced users, the plugin also allows you to add custom before and after HTML, and your own custom CSS as well.
Don’t forget to click on the save button to store your widget settings. You can now visit your website to see random posts widget in action.
Method 2: Display Random Posts in WordPress Using Code
This method requires you to add code to your WordPress theme files. See our guide on how to copy paste code in WordPress.
This code simply creates a function that displays 5 random posts. It then creates a shortcode so that you can easily display random posts anywhere on your site. Lastly, it enables shortcodes to be executed inside WordPress widgets so that you can use shortcode inside a text widget.
Now you can display random posts inside a WordPress post, page, or text widget using the shortcode [wpb-random-posts].