Home >CMS Tutorial >WordPress >How to make WordPress side widgets sort randomly
The following column WordPress Tutorial will introduce to you how to randomly sort WordPress side widgets. I hope it will be helpful to friends in need!
Sometimes you may want the sidebar widgets to be displayed in random order. You can add the following code to the end of the current theme template 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; }
Randomly sorting through front-end widgets can make your website layout constantly changing and display different content to viewers from time to time, thereby increasing the number of article reads.
The above is the detailed content of How to make WordPress side widgets sort randomly. For more information, please follow other related articles on the PHP Chinese website!