admin管理员组文章数量:1332395
I'm trying to write a wordpress function code in my child theme that randomizes the words in the word cloud where previously it was alphabetized.
The code Im using is below, which doesn't work.
//
add_filter('wp_tag_cloud_args', 'my_wp_tag_cloud_args_filter');
function my_wp_nav_menu_args_filter($args) {
$args['order'] = 'RAND';
// do something
return $args;
}
//
I'm able to update the wp_tag_cloud()'s default ('Order' = 'RAND') args in wp-includes/category-template.php but I know that any changes will get replaced. The change work when in that file.
How can I move those set of changes to my wordpress child theme?
I'm trying to write a wordpress function code in my child theme that randomizes the words in the word cloud where previously it was alphabetized.
The code Im using is below, which doesn't work.
//
add_filter('wp_tag_cloud_args', 'my_wp_tag_cloud_args_filter');
function my_wp_nav_menu_args_filter($args) {
$args['order'] = 'RAND';
// do something
return $args;
}
//
I'm able to update the wp_tag_cloud()'s default ('Order' = 'RAND') args in wp-includes/category-template.php but I know that any changes will get replaced. The change work when in that file.
How can I move those set of changes to my wordpress child theme?
Share Improve this question asked Jul 8, 2020 at 6:20 T. ThomasT. Thomas 6110 bronze badges1 Answer
Reset to default 1Try the tag_cloud_sort
hook:
add_filter( 'tag_cloud_sort', 'shuffle_tags', 10, 2 );
function shuffle_tags( $tags, $args ) {
shuffle( $tags );
return $tags;
}
本文标签: functionsRandomizing wptagcloud() in child theme
版权声明:本文标题:functions - Randomizing wp_tag_cloud() in child theme 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742283766a2446567.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论