ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Net Web >

No plugin, so that your WP tags Random color display

Sunday on February 2nd, 2020Net Web

WP lot of tags are randomly display different colors, looks can bring life to the blog, due to consult an expert, we found a way. The method can be said to be super-simple:

The following codes:

/ * Label color display start code * /

function colorCloud ($ text) {

$ Text = preg_replace_callback ( '|.? A (+) | i', 'colorCloudCallback', $ text);

return $ text;

}

function colorCloudCallback ($ matches) {

$ Text = $ matches [1];

$ Color = dechex (rand (0,16777215));

$ Pattern = '/style=('|")(.*)('|")/i';

$ Text = preg_replace ($ pattern, "", $ text);

return "a $ text

}

add_filter ( 'wp_tag_cloud', 'colorCloud', 1);

/ * Label color display end code * /

Copied to your theme (functions.php) in? Php. . . . . . . . Can be, I need you to look at home between?, Is not it pretty much the label change. . .

Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/netweb/No-plugin-so-that-your-WP-tags-Random-color-display.htm