Home > CMS Tutorial > WordPress > body text

How to make WordPress side widgets sort randomly

藏色散人
Release: 2019-11-21 10:48:48
Original
2752 people have browsed it

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!

How to make WordPress side widgets sort randomly

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!