最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

widgets - Sorting Tag Cloud by Popularity

programmeradmin2浏览0评论

So I have the default Wordpress Tag Cloud Widget on my sidebar/footer and I found the following code to limit the number that it's showing because it took up a ton of space. This code however is not actually showing the most popular tags, and I don't know what is causing this.

function set_widget_tag_cloud_args($args) {
  $my_args = array(
    'orderby'  => 'count',
    'order'    => 'DESC',
    'number'   => 15
  );
  $args = wp_parse_args( $args, $my_args );
return $args;
}
add_filter('widget_tag_cloud_args','set_widget_tag_cloud_args');

So it is restricting it to 15 tags correctly, but the orderby isn't working properly. For example, my most popular tags (by count) are "Piano" and "Bells" but these are not showing on the list at all. If I run the filter without the 'number' => 15 then the orderby count works properly, but then it shows 45 tags which is too much. Once I add the number arg back into the code it restricts it to 15, but its not displaying them in the right order.

Yellow shows tags across all limits, blue shows what tags are added upon increasing limit, red shows the top tags that don't appear under any limit, only default limit setting.

发布评论

评论列表(0)

  1. 暂无评论