Randomize posts on your archive pages

Most of the users don’t reach your second page on an archive page, so why not randomize your archive pages to get some hits for your older content.


Here is a really simple trick to randomize your category and tag arhives.
Just open functions.php in your theme folder and put this code in

// Random ordered on category pages
function shailan_post_order( $query ) {
    if ( $query->is_archive ) {
        $query->set( 'orderby', 'rand' );
    }
}
add_action( 'pre_get_posts', 'shailan_post_order' );

Just save and upload it.

Visit any archive page (category, tag archives etc) and you will see your posts are randomized!

Hope you like this trick. Enjoy!



NS Weight Release