Max Lynn
Max Lynn

Reputation: 1778

Wordpress - List out tags on template files

How do I list out all the tags to a template file?

I've looked at the wordpress documentation and found this..

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

However this doesn't output anything to my template.

Is there something that I am missing that i need to do on templates?

Upvotes: 0

Views: 66

Answers (1)

Vel
Vel

Reputation: 9331

Try this code

<?php
    $posttags  = get_terms( array(  'taxonomy' => 'post_tag') );

    if ($posttags ) {
        foreach($posttags  as $tag) {
            echo $tag->name . ' '; 
        }
    }
 ?>

Upvotes: 1

Related Questions