Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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"));
print_r($term_list);

Slightly adapted from http://codex.wordpress.org/Function_Reference/wp_get_post_terms#Examples

share|improve this answer
    
Thanks for response but I am getting this WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) ) –  mlets3113858 Feb 18 at 9:41
    
Any Idea about this? –  mlets3113858 Feb 18 at 9:42
    
Where do you call this? –  kraftner Feb 18 at 9:52
    
In single.php file. –  mlets3113858 Feb 18 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 at 9:59

This is how you can retrieve tags

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.