How to create a shortcode to list all tags on a page
-
Hello community,
I’m trying to output all the tags on a page, but for some reason it does not work.
Docs: get_tags and add_shortcode
Code for functions.php:
function get_all_tags($atts, $content = null ) { $tags = get_tags(); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>"; $html .= "{$tag->name}({$tag->count})</a>"; } $html .= '</div>'; return $html; } add_shortcode('alltags', 'get_all_tags');It looks simple, but for some reason I still miss something. Does someone have an idea or a hint for me?
Thanks a lot!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘How to create a shortcode to list all tags on a page’ is closed to new replies.