1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

get_the_tag_list() function - no Title attribute

Discussion in 'WordPress' started by sandeepdude, Oct 19, 2013.

  1. #1
    Hi,
    I am customising my wordpress theme to be more SE friendly.
    One thing I noted in my theme is that the tags are missing the title attribute.
    Example :
    <a href="" rel="tag">Tag 1</a>
    Code (markup):
    On Analysing my theme, get_the_tag_list() function is used to populate the tags.

    How can I make the tags appear as below?
    <a href="" rel="tag" title="Tag 1">Tag 1</a>
    Code (markup):
    I checked in the Codex reference but didnt find any solution.

    Let me know if you can help me in getting this to work.

    Thanks,
    Sandeep
     
    sandeepdude, Oct 19, 2013 IP
  2. Hefaistos

    Hefaistos Active Member

    Messages:
    194
    Likes Received:
    14
    Best Answers:
    9
    Trophy Points:
    63
    Digital Goods:
    1
    #2
    Use get_the_tags() .
    <?php
    $post_tags = get_the_tags();
    if ($post_tags) {
      foreach($post_tags as $tag) {
        echo '<a href=" '. get_tag_link($tag->term_id) .' " rel="tag" title=" '. $tag->name .' ">'. $tag->name .'</a>,';
      }
    }
    ?>
    PHP:
     
    Hefaistos, Oct 19, 2013 IP
    sandeepdude likes this.