2

How can I call the_tags as a list without hyperlinks?

5
<ul>
   <?php
    $tags = get_tags();

    foreach($tags as $tag) {
        echo "<li>$tag->name</li>";
   }
   ?>

</ul>
  • Thanks Ethan. Are there any other methods that will return the post tags with a separator and no links? – Scott B Feb 9 '11 at 12:37
  • This is the only one that I know of. All other functions return tags as links. You could always write your own function. :) – Ethan Seifert Feb 9 '11 at 17:30
2

It shows the tags of your post. If you use "get_tags()" you will list all tags of wordpress.

   <?php
    if (is_array(get_the_tags())) {
           $tags = get_the_tags();
           foreach($tags as $tag) {
              echo "$tag->name";
           } 
        } 
    ?>

You should check the get_the_tags() if "is_array()" or you'll get error case the_post() doesn't have a tag .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.