• Hello,

    I would like to add a extension to the tag link. For example if it is HTML will be something like this:

    From
    <a href="https://website.com/tag/example">Example</a>

    To
    <a href="https://website.com/tag/example?e_xtantion">Example</a>

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • are you referring to post tags or the tag cloud widget?

    what function is used for that?

    is that always going to be the same extension for all tags?

    Thread Starter klo-wp

    (@klo-wp)

    I am referring to post tag, and will the same extension for all tags, if a certain condition is met. The condition is that the post should has a tag. With condition i think i can sort out.

    Actually I use a specific function to hide a specific tag.

    Here is the code I use in function.php

    function pk_the_tags( $before = '', $sep = ', ', $after = '', $exclude = '' ) {
            $tags = get_the_tags();
            if ( empty( $tags ) )
                    return false;
            $tag_list = $before;
            foreach ( $tags as $tag ) {
                     if (!empty($exclude))
                            $pos = stripos( $exclude, $tag->name);
                     else
                            $pos = false;
                     if ($pos=== false)
                            $tag_links[] = '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
            }
            if (empty($tag_links))
               return false;
            $tag_links = join( $sep, $tag_links );
            $tag_links = apply_filters( 'the_tags', $tag_links );
            $tag_list .= $tag_links;
            $tag_list .= $after;
            echo $tag_list;
    }

    and in single.php

    <?php if (get_the_tags()) pk_the_tags('<span>', '</span><span>', '</span>', 'my_tag_name'); ?>

    So the my_tag_name will not be showed in the post with the code above.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to customize the Tag link’ is closed to new replies.