Custom WordPress tag cloud and WooCommerce product tag cloud widget

Default, the WordPress tag cloud widget has a set amount of 45 tags to display. This can be seen in the wp-includes/category-template.php file.

And the WooCommerce plugin which I have installed, and it’s products tag cloud widget also resembles this. How do I modify this amount from within my wp-content/themes/functions.php file, to display for example, only 15 product tags or other?

For WordPress Tag Cloud widget:

function custom_tag_cloud_widget() {
    $args = array(
        'smallest' => 8,
        'largest' => 22,
        'unit' => 'pt',
        'number' => 15,
        'format' => 'flat',
        'separator' => "\n",
        'orderby' => 'name',
        'order' => 'ASC',
        'exclude' => '',
        'include' => '',
        'link' => 'view',
        'taxonomy' => 'post_tag',
        'post_type' => '',
        'echo' => true
    );
    return $args;
}
add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' );

For WooCommerce Product Tags widget:

function custom_woocommerce_tag_cloud_widget() {
    $args = array(
        'number' => 15,
        'taxonomy' => 'product_tag'
    );
    return $args;
}
add_filter( 'woocommerce_product_tag_cloud_widget_args', 'custom_woocommerce_tag_cloud_widget' );
Share this :

Comments are closed.

Related post

Free Responsive Website templates

ThemeVina is Best site for free sharing and download Wordpress themes, Joomla templates, Responsive website templates and more HTML templates.

All template in Site are free. You can download and install for your site.

Contact us

  • Brand: Theme Vina
  • Email: admin@themevina.com
  • Website: www.themevina.com
  • Address: 367 Tran Hung Dao Street
  • Location: Thai Binh City, Thai Binh, Viet Nam

Newsletter