• Hi all!

    Does anybody knows how i can get and echo the topics count of the current tag on a ngg tag page?

    If i click on a tag in my nextgen tagcloud i get a result page. On this page i want to echo how many images there are on this page with the same tag.

    I found this code

    <?php
    $tags = (array) nggTags::find_tags($param, true);
    foreach( $tags as $tag ) {
    echo '<li><span>' . esc_html( $tag->name ). '</span>&nbsp;'.'('. esc_html( $tag->count ).')</li>'."\n";
    
    				}
    				unset($tags);
    ?>

    But this generates a list of all the tags with their count, I only need the count of the current tag.

    anybody?

    kind regards

    http://wordpress.org/extend/plugins/nextgen-gallery/

Viewing 1 replies (of 1 total)
  • Hello Arthur,

    at a quick look, I’d say that the $param variable should be used to filter the $tags array. I guess you could write there the name of the current tag.

    If this doesn’t work one could try to filter the $tags array, but this could be difficult to obtain with native php methods because $tags elements are object variables.

    A crude method would be to run through all the array but echoing only if the tag name is the one you want:

    <?php
    $tags = (array) nggTags::find_tags($param, true);
    foreach( $tags as $tag ) {
    	if(esc_html( $tag->name ) == $your_tag_name) {
    		echo '<li><span>' . esc_html( $tag->name ). '</span>&nbsp;'.'('. esc_html( $tag->count ).')</li>'."\n";
    		break;
    	}
    }
    unset($tags);
    ?>

    while I am here, another thing. unfortunately I noticed only now that very long time ago you asked me about my hack to display a gallery selected by using multiple tags in a logical AND fashion:

    http://tinyurl.com/7oh7two

    let me know if you still wish help with that.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: NextGEN Gallery] Get the current tag count and echo it’ is closed to new replies.