Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This seems like it should be something that's really simple to do, however it's apparently not.

I don't want tags to be links, but I want them to display in an unordered list, with each tag inside an <li>

get_the_tags allows you to echo them without the associated link, but I have no idea how to wrap them in li's.

 <?php
$posttags = get_the_tags();
if ($posttags) {
  foreach($posttags as $tag) {
    echo $tag->name . ' '; 
  }
}
?>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

This would do it...

 <?php
$posttags = get_the_tags();
if ($posttags) {
  foreach($posttags as $tag) {
    echo '<li>' .$tag->name. '</li>'; 
  }
}
?>
share|improve this answer
    
Please explain why that could solve the problem. –  toscho Jan 10 '13 at 4:00
    
Thanks! What are the fullstops on either side of the $tag->name for? –  andy Jan 10 '13 at 4:41
    
The periods? In PHP that's the string concatenation operator. –  Doug Oct 8 at 22:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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