Site logo

[Resolved] Creating a list of TAGS with post count

Home Forums Support [Resolved] Creating a list of TAGS with post count

Home Forums Support Creating a list of TAGS with post count

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2458804
    ch1800

    Hello,

    I’m not sure this would be supported here but here we go:

    Is it possible to create a simple and basic HTML-linked list of all TAGS used at a website with their corresponding count of posts?
    Nothing fancy, no cloud rendering, just a basic list that displays all tags with the post count and that is hyperlinked to each tag archive page.

    Thanks.

    #2458947
    David
    Staff
    Customer Support

    Hi there,

    you can create a Shortcode using this PHP Snippet:

    
    add_shortcode ('show_tags', function($html){
        $html = '<ul class="tags-list">';
        $terms = get_terms('post_tag',array('hide_empty'=>false));
        foreach( $terms as $t) {
            $html .= sprintf(
                '<li><a href="%1$s" title="%2$s">%2$s (%3$s)</a></lia>',
                $term_link = get_term_link( $t ),
                $t->name,
                $t->count
            );
        }
        $html .= '</ul>';
        return $html;
    });

    Then add the [show_tags] shortcode to your page.

    #2458962
    ch1800

    Wonderful! Many thanks for this.

    #2459190
    David
    Staff
    Customer Support

    Awesome – glad to be of help!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.