menu search
brightness_auto
Ask or Answer anything Anonymously! No sign-up is needed!
more_vert
I have a wordpress blog with a premium theme running on it. How can I show random posts on default homepage instead of recent posts / reverse chronological order? I want to show random posts to visitors each time they reload the homepage. I tried several plugins but they all are just for showing as a widget. I want the same style of wordpress default list page or the themes list style. Is there any plugin or code to do this? I prefer not to use a plugin.
more_vert
There is no plugin or code to do this - it is a standard feature of wordpress that can be found in the source code of the plugins you mention.

7 Answers

more_vert

Yes you can change recent posts on default WordPress homepage to random posts without using a plugin. You just need to add a code to your active theme's functions.php file. If you are using a child theme you have to change the functions.php file in child theme only. As you are using a premium theme most probably there must be a child theme on it.


Add the below code to child theme's functions.php

add_action('pre_get_posts','alter_query'); function alter_query($query){ if ($query->is_main_query() &&  is_home()) $query->set('orderby', 'rand'); //Set the order to random }

Now your wordpress will start showing random posts instead of recent posts. Remember if you are using caching on homepage then the posts may not change on every pageloads.

thumb_up_off_alt 1 like thumb_down_off_alt 0 dislike
more_vert
By default, WordPress displays all the posts on the homepage in reverse chronological order. This works out great for sites with continuously changing content like a news or technology blog. However, this leads to what I feel is a huge “wastage” of content that can still be relevant. Not all content is time sensitive. An outdated news story certainly doesn’t need to be resurfaced. But
an interesting political analysis might always be relevant. We’ve talked about republishing older blog posts before, and that’s one way to get leverage out of
your existing content. But what if you could
randomly serve up blog posts on your homepage
everytime a visitor viewed it? There are lots of plugins and pieces of code that show you random blog posts on the sidebar in the form of a widget. But so far, I haven’t seen anything that displays a random blog post on the homepage.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert

There are 2 method to show random post on WordPress

  1. Display random post in WordPress with a plugin
  2. This method is easier and is recommended for most users. First thing you need to do is install and activate the Advanced random post widget plugin. Upon activation, you need to visit Appearance>Widgets page.You will notice a new widget labeled Random post under the list of available widget. Advanced random post widget is a powerful pludgin withn tons of customization options. Dont forget to click save button to store your widget settings. You can now visit your website to see random posts widget in action
  3. Display random posts in WordPress using codes
  4. This method requires you to add code to your WordPress theme site. First thing you need to do is code your theme's functions.php file or a site-specific pludgin. This code simply creates a function that display 5 random post. It then creates a shortcode so that you can easily display random post anywhere on your site. Lastly, it enables shortcode to be axecuted 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.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert
To display random posts on your WordPress homepage, you can use the WP_Query class and set the 'orderby' parameter to 'rand'. Here is an example of how you could do this:

<?php

$args = array(

 'posts_per_page' => 5, // Number of posts to display

 'orderby' => 'rand', // Random order

);

$query = new WP_Query( $args );

if ( $query->have_posts() ) {

 while ( $query->have_posts() ) {

  $query->the_post();

  // Display post content here

 }

 wp_reset_postdata();

}

?>

This code will display a random selection of 5 posts on your homepage. You can adjust the 'posts_per_page' parameter to control the number of posts that are displayed.

You can also use the 'orderby' => 'rand' parameter in other WordPress queries to display random posts in other contexts. For example, you could use it to display a random selection of posts in a widget or in a shortcode.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert
There is no plugin or code to do this. You can simply add the following to your blog's onpagepeed.com landing page:

In order to show random posts on this homepage, you will need to include one or more of your other blog posts as part of your main content. You can find these posts by clicking on the "Some other blog posts you'll love" link at the top of your blog's onpagepeed.com landing page. Once you have selected these posts, you will see a list of posts from that blog selection.yason will show you how to add random posts to this homepage using that blog.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert
 Yes, there is a plugin that does this called WPBakery Pageiamo.

..................................................................................................................................................
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert
The best way to show random posts on your WordPress website will vary depending on the theme and configuration of your website. However, one potential solution is to use a WordPress plugin called Random Post. Random Post provides a simple way to show a random post from your blog on your website's default homepage, and it can be configured to show posts from any time period or category.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
Welcome to Answeree, where you can ask questions and receive answers from other members of the community.
...