Skip to content

Instantly share code, notes, and snippets.

@cubehrends
Last active March 2, 2020 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cubehrends/eeea59721d06d3acb9ab7faa2014a104 to your computer and use it in GitHub Desktop.
Save cubehrends/eeea59721d06d3acb9ab7faa2014a104 to your computer and use it in GitHub Desktop.
<?php
/* Shortcode to Display Post Tags in UnorderedList /w specific CSS-Class and Link to Archive
=============================================================== */
function display_tags( $atts, $content = null ) {
$post_tags = get_the_tags();
if ( $post_tags ) {
$html = '<ul class="tag-list">';
foreach( $post_tags as $tag ) {
$html .= '<li><a class="' . $tag->slug . '" href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
}
$html .= '</ul>';
}
return $html;
}
add_shortcode( 'display-tags', 'display_tags' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment