I was able to locate part of the answer, I'm new to Wordpress. Im looking to show random post on the main page, but except the last post i found this
add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts($query) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set('orderby', 'rand');
}
}
Thank you in advance
Please use it and I 'm also searching a best possible solution in which you need not to enter the static last post id =1 .Here is the code please use this code in functions.php file and enter the last post id which you need to exclude the post.
Thanking you.