WordPress Tag Cloud Filter Prevents Widget HTML from loading

admin2025-06-03  2

I have a sidebar in wordpress registered like this:

    register_sidebar( array(
    'name'          => 'Blog Sidebar',
    'id'            => 'blog_sidebar',
    'before_widget' => '<div class="widget-wrapper col-xs-12 col-sm-6 col-md-6 col-lg-12">',
    'after_widget'  => '</div>',
    'before_title'  => '<h2 class="widget-title">',
    'after_title'   => '</h2>',
) );

Then, I'm dropping the tag cloud widget in there. It produces the widget code with title wrapped in <h2> and widget code wrapped in a <div> with classes above. So far, so good.

Now, I need to make some changes to how tag cloud is displayed, so I add a filter like so:

add_filter('widget_tag_cloud_args','set_tag_cloud_features');
  function set_tag_cloud_features($args) {
    $args = array(
        'smallest'    => 18, 
        'default' => 18, 
        'largest'    => 18, 
        'unit' => 'px',
        'show_count' => 1,
        'format' => 'list',
        'orderby' => 'count',
        'order' => 'DESC'
    );
    return $args;
}

Somehow this messes up the widget HTML now. <h2> and the widget wrapper <div> are gone. Looking at the wp_tag_cloud function reference, I don't see how to pass any arguments to avoid this...

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748939175a314992.html

最新回复(0)