$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>WordPress Tag Cloud Filter Prevents Widget HTML from loading|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

WordPress Tag Cloud Filter Prevents Widget HTML from loading

matteradmin9PV0评论

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...

Post a comment

comment list (0)

  1. No comments so far