Skip to content

Instantly share code, notes, and snippets.

@Davidlab
Last active December 14, 2015 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Davidlab/5130772 to your computer and use it in GitHub Desktop.
Save Davidlab/5130772 to your computer and use it in GitHub Desktop.
Justified Image Grid Nexgen Tags. Paste this into your themes functions.php and use shortcode [justified_ngg_tagcloud]
function justified_tag_cloud($args ='', $template = '') {
global $nggRewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'
);
$args = wp_parse_args( $args, $defaults );
$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
foreach ($tags as $key => $tag ) {
$tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug));
$tags[ $key ]->id = $tag->term_id;
}
$out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>';
return $out;
}
function show_tagcloud_justified( $atts ) {
extract(shortcode_atts(array(
'template' => ''
), $atts));
$out = justified_tag_cloud( '' );
return $out;
}
add_shortcode( 'justified_ngg_tagcloud', 'show_tagcloud_justified' );
@totzo
Copy link

totzo commented May 29, 2013

Hi there,

I just got the jig plugin and found your code really useful. I was wondering if there is a way to reference the "current" tag for styling so I can have the current tag a diferent colour from the other tag links for example:

ngg-tagcloud current_tag {
color: rgb(68, 68, 68);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment