Archived topic
Shortcode Tags with a link
1 reply · Started by Den on March 20, 2021
Viewing posts 1–2 of 2
Hi team,
I want to show tags using a shortcode. But it only shows the text and that too as a bullet point. (that I don’t want)
For example: DON’T WANT
- Tag 1
- Tag 2
Example: WANT
I want the tags to be a link
Here’s the code that i added on my functions.php
function getTagList($classes = '') {
global $post;
$tags = get_the_tags($post->ID);
$tagOutput = [];
if (!empty($tags)) {
array_push($tagOutput, '<ul class="tag-list '.$classes.'">');
foreach($tags as $tag) {
array_push($tagOutput, '<li>'.$tag->name.'</li>');
}
array_push($tagOutput, '</ul>');
}
return implode('', $tagOutput);
}
add_shortcode('tagsList', 'getTagList');
I already replied here:
https://generatepress.com/forums/topic/entry-meta-shortcode/#post-1702986
This archived topic is closed to new replies.