I must put the post's tags as a paragraph under the article in my single.php page, this is my code:

<?php $post_tags = wp_get_post_tags($post->ID);
 if(!empty($post_tags)) {?>
            <p><?php the_tags('', ' ', ''); ?></p>
        <?php } ?>

Why it's not working?


Run a loop to output your tags:

$posttags = get_the_tags($post->ID);
if ($posttags) {
    foreach($posttags as $tag) {
        echo '<a href="'.get_tag_link($tag->term_id).'" title="'.$tag->name.'">'. $tag->name .'</a>'; 

You don't have to provide $post->ID if you are using this inside a loop.

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.