Last active
March 2, 2020 07:44
-
-
Save cubehrends/eeea59721d06d3acb9ab7faa2014a104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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