nggTagCloud

NggTagCloud() - return a tag cloud based on the wp core tag cloud system.

Description

nggTagCloud( (string) $args = '', (string) $template = '' ); 

Parameters (2)

0. $args — Optional. (string) => ''
The args.
1. $template — Optional. (string) => ''
name for a template file, look for gallery-$template

Usage

  1. if ( !function_exists( 'nggTagCloud' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // The args. 
  5. $args = ''; 
  6.  
  7. // (optional) name for a template file, look for gallery-$template 
  8. $template = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = nggTagCloud($args, $template); 
  12.  

Defined (1)

The function is defined in the following location(s).

/nggfunctions.php  
  1. function nggTagCloud($args ='', $template = '') { 
  2. global $nggRewrite; 
  3.  
  4. // $_GET from wp_query 
  5. $tag = get_query_var('gallerytag'); 
  6. $pageid = get_query_var('pageid'); 
  7.  
  8. // look for gallerytag variable 
  9. if ( $pageid == get_the_ID() || !is_home() ) { 
  10. if (!empty( $tag )) { 
  11.  
  12. $slug = esc_attr( $tag ); 
  13. $out = nggShowGalleryTags( $slug ); 
  14. return $out; 
  15.  
  16. $defaults = array( 
  17. 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,  
  18. 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',  
  19. 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag' 
  20. ); 
  21. $args = wp_parse_args( $args, $defaults ); 
  22.  
  23. $tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags 
  24.  
  25. foreach ($tags as $key => $tag ) { 
  26.  
  27. $tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug)); 
  28. $tags[ $key ]->id = $tag->term_id; 
  29.  
  30. $out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>'; 
  31.  
  32. return $out;