How to Limit the no of Tag in Tag Cloud in WordPress

Posted by on Jul 4, 2011 in web designing | 2 comments

How to Limit the number of Tag in Tag Cloud in WordPress

  • In WordPress we have this tag cloud features but most of us don’t wants to show as much tag cloud as it shows by default,
  • there are many reason for Limit the number of Tag in Tag Cloud like too many tag in tag cloud increase the total no of links in our single page which is not good for search engine because google bot only chrol max 100 links from single page most of time and leave rest,
  • that’s why we have to control the total no of tag in the tag cloud,
Tag Cloud in WordPress 1

How to Limit the no of Tag in Tag Cloud in WordPress

How to control the tag no in tag cloud –

  • In WordPress there is category template.php for this all category and tag management, so if we wants to control the tag cloud and wants to change in the appearance og these tag no and style then we have to change in this category-template.php file,
  • this category-tmplate.php is located in the Include folder you can find it in your root domain, by using any ftp client like filezilla ,

step 1 –

  • open your ftp client and go to your include folder and download the file category-tmplate.php and save it,
  • save a copy of it at safe place for security purpose if anything misshapen,
Tag Cloud in WordPress 2

How to Limit the no of Tag in Tag Cloud in WordPress

step 2 –

  • now open it in text editor notepad or anything and  find the Display tag cloud by ctrl + f, as shown in image above,
  • now scroll down and you will find the code 1 , given below

 

function wp_tag_cloud( $args = '' ) {
    $defaults = array(
        'smallest' => 8, 'largest' => 20, 'unit' => 'pt', 'number' => 45,
        'format' => 'flat', 'separator' => "n", 'orderby' => 'name', 'order' => 'ASC',
        'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true
    );
    $args = wp_parse_args( $args, $defaults );

    $tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags

 

  • now  just change the ‘number’ => 45,  to any no you wants to show
  • ‘largest’ => 20 for largest font size,
  • ‘smallest’ => 8, smallest font size
  • and now just save the file after changing it,

step 3 –

  • no all done just replace the file in Include folder category-tmplate.php .
  • now you have total control in tag cloud.