Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Natasha McDiarmid
Natasha McDiarmid
11,400 Points

How to remove 'tags' from get_tags output

How can I remove the title, 'tags' from the outputted list of tags?

This is the code I am using.

               <?php 
            $tags = get_tags();
            $html = '<div class="post_tags">';
            foreach ( $tags as $tag ) {
                $tag_link = get_tag_link( $tag->term_id );

                $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
                $html .= "{$tag->name}</a>";
                }
            $html .= '</div>';
            echo $html; 
        ?>

I just want to output the list of tags in WordPress.

2 Answers

Natasha McDiarmid
Natasha McDiarmid
11,400 Points

This worked:

<?php the_tags(' ', ' | ', ''); ?>
Brad Van Skyhawk
Brad Van Skyhawk
28,489 Points

I would think something like this to get the tags into an array:

<?php $tags = get_tags(); $list = array(); foreach ( $tags as $tag ) { $list[] = $tag->name; } ?>