Want more features on Pastebin? Sign Up, it's FREE!
Guest

nggTagCloud

By: a guest on Apr 7th, 2012  |  syntax: None  |  size: 1.52 KB  |  views: 72  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  
  3.  * nggTagCloud() - return a tag cloud based on the wp core tag cloud system
  4.  
  5.  *
  6.  
  7.  * @param array $args
  8.  
  9.  * @param string $template (optional) name for a template file, look for gallery-$template
  10.  
  11.  * @return the content
  12.  
  13.  */
  14.  
  15. function nggTagCloud($args ='', $template = '') {
  16.  
  17.     global $nggRewrite;
  18.  
  19.  
  20.  
  21.     // $_GET from wp_query
  22.  
  23.     $tag     = get_query_var('gallerytag');
  24.  
  25.     $pageid  = get_query_var('pageid');
  26.  
  27.    
  28.  
  29.     // look for gallerytag variable
  30.  
  31.     if ( $pageid == get_the_ID() || !is_home() )  {
  32.  
  33.         if (!empty( $tag ))  {
  34.  
  35.    
  36.  
  37.             $slug =  esc_attr( $tag );
  38.  
  39.             $out  =  nggShowGalleryTags( $slug );
  40.  
  41.             return $out;
  42.  
  43.         }
  44.  
  45.     }
  46.  
  47.    
  48.  
  49.     $defaults = array(
  50.  
  51.         'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
  52.  
  53.         'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
  54.  
  55.         'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'
  56.  
  57.     );
  58.  
  59.     $args = wp_parse_args( $args, $defaults );
  60.  
  61.  
  62.  
  63.     $tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
  64.  
  65.  
  66.  
  67.     foreach ($tags as $key => $tag ) {
  68.  
  69.  
  70.  
  71.         $tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug));
  72.  
  73.         $tags[ $key ]->id = $tag->term_id;
  74.  
  75.     }
  76.  
  77.    
  78.  
  79.     $out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>';
  80.  
  81.    
  82.  
  83.     return $out;
  84.  
  85. }
  86.  
  87. ?>
clone this paste RAW Paste Data