After Updating OceanWP Theme Randomizing Homepage Stopped Working

I Have 2 similar websites both created on oceanwp Maria theme .

I Wanted To Randomized Posts On My Homepage So I Added This code ⏬ In Function.php of both websites

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 }

But After Recent Updates On OceanWp Theme This code is not working on my updated theme website & is working fine on website which has not been updated yet

edit :- After Updating theme I added the code again in Function.php & now its working

<solved>

  • This topic was modified 15 minutes ago by pank6119.

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer