Random Post In WordPress

Now I learnt in wordperss “How to display random post in home page”. It is very easy. Just we have to add action in “pre_get_posts” tag. I added sourcecode below

<?php
add_action('pre_get_posts','bscode_random_post');
function bscode_random_post($query){    
    if($query->is_home && empty($query->query_vars['suppress_filters'])){
        $query->set('orderby','rand');
    }
}

?>