bbPress Tag Cloud – Change font size, Change number of Tags

Home Forums BulletProof Security Pro bbPress Tag Cloud – Change font size, Change number of Tags

This topic contains 0 replies, has 1 voice, and was last updated by  AITpro Admin 5 years, 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #13397

    AITpro Admin
    Keymaster

    The title of this Topic is created for better searchability since most folks will be doing the same Google searches I was doing to try and figure out how to control and change the font size and total number of bbPress Topic Tags.  The solution is actually to create your own Text widget that uses the bbPress taxonomy bbp_get_topic_tag_tax_id() function instead of trying to add a filter for the existing bbPress Topic Tag cloud code.

    bbPress is using the WordPress wp_tag_cloud() function in this bbPress file:  /bbpress/includes/common/shortcodes.php – Code line 522 and it is designed to hook into the WordPress Text widget by using this filter in your Theme’s functions.php file: add_filter( 'widget_text', 'do_shortcode' );. Since there is nothing magical going on here (besides the bbPress taxonomy magic itself  😉 ) then it is simpler just to use the same WordPress wp_tag_cloud() function in your Theme’s functions.php file and of course include the bbPress taxonomy bbp_get_topic_tag_tax_id() function in your code.

    Go to WordPress Appearances >>> Widgets >>> drag the WordPress Text Widget to your Sidebar.  Add the code below in your Theme’s functions.php file and then change the font sizes and number of tags that you want displayed.

    add_filter( 'widget_text', 'wp_text_widget_tag_cloud', 10 );
    
    function wp_text_widget_tag_cloud() {
    
    if ( function_exists('wp_tag_cloud') ) : ?>
    
    <h3 class="widgettitle">Topic Tags</h3>
    
    <?php
    
    wp_tag_cloud( array(
    'smallest' => 10,
    'largest' => 22,
    'number' => 100,
    'taxonomy' => bbp_get_topic_tag_tax_id()
    ) );
    endif;
    }

    …Or…

    If you are happy with the default bbPress Tag font sizes and number of Tags displayed then  go to WordPress Appearances >>> Widgets >>> drag the WordPress Text Widget to your Sidebar >>> Add the Title you want to use “Topic Tags” etc.  Add this bbPress shortcode:  [bbp-topic-tags] in the Text Widget window >>> add this code to your Theme’s functions.php file:  add_filter( 'widget_text', 'do_shortcode' );. The default bbPress Tag sizes and number of Tags will be displayed in your Sidebar.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.