Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of random sorting of WordPress side gadgets

Shulou Source: shulou.com Published: 2022-06-02 05:07:31 10月01日 Update

How to let the WordPress side gadget sort randomly? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

Sometimes you may want the sidebar gadget to display in random order, you can add the following code to the end of the current theme template function functions.php file:

Add_filter ('sidebars_widgets',' zm_randomize_widget_order'); function zm_randomize_widget_order ($sidebars_widgets) {if (! is_admin ()) {foreach ($sidebars_widgets as & $widget) {shuffle ($widget);}} return $sidebars_widgets;}

Through the random sorting of the foreground gadget, you can constantly change the layout of your website and show different content to visitors from time to time, thus increasing the amount of articles to be read.

Thank you for reading! After reading the above, do you have a general idea of how to sort the WordPress side gadgets at random? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Tags: Content tools sorting side articles methods questions different constantly themes code functions foreground layout files more templates visitors look website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Redmi Xiaomi NVidia