apply_filters( 'widget_tag_cloud_args', array $args, array $instance )

Filters the taxonomy used in the Tag Cloud widget.


Description Description

See also See also


Top ↑

Parameters Parameters

$args

(array) Args used for the tag cloud widget.

$instance

(array) Array of settings for the current widget.


Top ↑

More Information More Information

By default, the following parameters are available to $args:

  • smallest – The smallest tag (lowest count) is shown at size 8
  • largest – The largest tag (highest count) is shown at size 22
  • unit – Describes ‘pt’ (point) as the font-size unit for the smallest and largest values
  • number – Displays at most 45 tags
  • format – Displays the tags in flat (separated by whitespace) style
  • separator – Displays whitespace between tags
  • orderby – Order the tags by name
  • order – Sort the tags in ASCENDING fashion
  • exclude – Exclude no tags
  • include – Include all tags
  • link – view
  • taxonomy – Use post tags for basis of cloud
  • echo – echo the results

Top ↑

Source Source

File: wp-includes/widgets/class-wp-widget-tag-cloud.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 Added the $instance parameter.
3.0.0 Added taxonomy drop-down.
2.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Mahdi Yazdani

    Modifies tag cloud widget arguments to display all tags in the same font size and use list format for better accessibility.

    /**
     * Modifies tag cloud widget arguments to display all tags in the same font size
     * and use list format for better accessibility.
     *
     * @param 	array $args Arguments for tag cloud widget.
     * @return 	array The filtered arguments for tag cloud widget.
     */
    function prefix_widget_tag_cloud_args( $args ) {
    	$args['largest']  = 1;
    	$args['smallest'] = 1;
    	$args['unit']     = 'em';
    	$args['format']   = 'list';
    
    	return $args;
    }
    
    add_filter( 'widget_tag_cloud_args',    'prefix_widget_tag_cloud_args' 		10, 1 );
    
  2. Skip to note 2 content
    Contributed by stevenlinx

    Example Migrated from Codex:

    Include specific tag IDs in tag cloud widget.

    add_filter( 'widget_tag_cloud_args', 'filter_tag_cloud_widget' );
    
    function filter_tag_cloud_widget($args, $instance) {
    
        $include = array( 58, 59 );
    
        $args = array(
            'include' => $include,
            'taxonomy' => $current_taxonomy,
            'echo' => false,     
        );
    
        return $args;
    }
    

You must log in before being able to contribute a note or feedback.