I have created one post and post ID is 34 and added some Tags and Now I want to retrieve all tags with post ID.

enter image description here

Any Idea?


This is how you can retrieve tags

$tax_tags = get_terms(array('post_tag'));
   foreach($tax_tags as $tag){
     <?php echo ucfirst($tag->taxonomy).' : ' ?>
         <a href="<?php echo get_term_link($tag); ?>"><?php echo $tag->name ?></a>

Customize it the way you like.

get_terms(array('post-tag')); fetches you tag related to a post.

You can put this code within or outsode the default loop.

Reference: get_terms


Put this inside your loop:

//Returns All Term Items for "my_term"
$term_list = wp_get_post_terms($post->ID, 'post_tag', array("fields" => "all"));

Slightly adapted from wp_get_post_terms

  • Thanks for response but I am getting this WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) ) – Mr.Happy Feb 18 '14 at 9:41
  • Any Idea about this? – Mr.Happy Feb 18 '14 at 9:42
  • Where do you call this? – kraftner Feb 18 '14 at 9:52
  • In single.php file. – Mr.Happy Feb 18 '14 at 9:52
  • 1
    You are using standard tags, not some custom taxonomy, right? I just tested the code and it works here. Check if you copied everything as I wrote it. – kraftner Feb 18 '14 at 9:59

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.