I want to display the tags of the current post in the single.php and do the following:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1 class="single_h"><?php the_title(); ?></h1> 
    <p class="single_subline"><?php echo get_post_meta($post->ID, 'subline', true) ?></p>
    <!-- everythings fine til here -->   
    <p class="single_tags"><?php echo wp_get_post_tags($post->ID); ?></p> 
<?php endwhile; endif; ?> 

and everything just works fine, except the wp_get_post_tags method. All I get displayed inside the .single_tags is the string Array.

I am new to wordpress and would like to know what I am doing wrong.


  • 1
    Have you tried the_tags()? – Chip Bennett Apr 16 '14 at 13:27
  • @ChipBennett works! But don't get whats wrong with my approach! Anyway, thank you very much! – user49869 Apr 16 '14 at 13:33

You're getting Array because that's exactly what wp_get_post_tags returns; an array (and when you try and echo one in PHP it'll simply output Array).

As @Chip Bennet suggested, use the_tags() instead, which outputs an HTML string.

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.