Display most popular Product Tags and limit the number of tags to be display

This topic has 4 replies, 3 voices, and was last updated 9 months, 2 weeks ago ago by Andrew Mitchell

  • Avatar: Rodlens Hora
    Rodlens Hora
    Participant
    February 10, 2024 at 05:09

    Display most popular Product Tags in the widget and limit the number of tags to be display.

    i found a code it work but not well integrate with the theme
    10,
    ‘largest’ => 22,
    ‘unit’ => ‘px’,
    ‘number’ => 10,
    ‘format’ => ‘flat’,
    ‘separator’ => ” “,
    ‘orderby’ => ‘count’,
    ‘order’ => ‘DESC’,
    ‘show_count’ => 3,
    ‘echo’ => false
    );
    $tag_string = wp_generate_tag_cloud( $tags, $args );
    return $tag_string;
    }
    // Add a shortcode so that we can use it in widgets, posts, and pages
    add_shortcode(‘wpb_popular_tags’, ‘wpb_tag_cloud’);
    // Enable shortcode execution in text widget
    add_filter (‘widget_text’, ‘do_shortcode’);

    can you guys help me with that

    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    February 10, 2024 at 09:08

    Dear Rodlens Hora,

    We hope this message finds you well.

    We would like to guide you through the process of limiting the number of tags displayed in the product tag cloud on your website. To achieve this, kindly insert the following code snippet into the functions.php file located within your child theme directory:

    
    function n2t_topic_count_text( $count ) {
        /* translators: %s: product count */
        return sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) );
    }
    
    add_filter('woocommerce_product_tag_cloud_widget_args', 'n2t_woocommerce_product_tag_cloud_widget_args', 100);
    function n2t_woocommerce_product_tag_cloud_widget_args() {
        return array(
            'taxonomy'                  => 'product_tag',
            'topic_count_text_callback' => 'n2t_topic_count_text',
            'number'                    => 10,
            'orderby'                   => 'count',
            'order'                     => 'DESC',
            'show_count'                => 3,
            'smallest'                  => 10,
            'largest'                   => 22,
            'unit'                      => 'px',
        );
    }
    

    Once you have added the code, please proceed to the Widgets section of your WordPress dashboard. There, you should add the Product Tag Cloud widget to the Shop Sidebar. For your convenience, here are the visual guides to assist you:

    – [Widget Addition Guide 1](https://prnt.sc/S1sjXuxEIEOH)
    – [Widget Addition Guide 2](https://prnt.sc/17R_IDP69Jcr)

    Should you require any further assistance, please do not hesitate to reach out.

    Best regards,
    The 8Theme Team

    Avatar: Rodlens Hora
    Rodlens Hora
    Participant
    February 10, 2024 at 19:57

    Thanks, I very appreciate that you all doing an amazing job

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 10, 2024 at 19:57

    Dear Rodlens Hora,

    In the spirit of gratitude, we want to express our appreciation for your trust in our products. As a valued customer, your experience matters greatly. Would you consider sharing it by giving our theme a deserving 5-star rating on ThemeForest?

    Click here to share your thoughts: https://themeforest.net/downloads

    Being part of our community means a lot, and your feedback contributes immensely.

    Best Regards,
    The 8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Display most popular Product Tags and limit the number of tags to be display’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.