Site logo

[Resolved] Shortcode Tags with a link

Home Forums Support [Resolved] Shortcode Tags with a link

Home Forums Support Shortcode Tags with a link

  • This topic has 1 reply, 2 voices, and was last updated 5 years ago by David.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1702583
    Den

    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

    Tag 1, Tag 2

    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');
    #1702987
    David
    Staff
    Customer Support
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.