0

This question is an exact duplicate of:

I want to list tags of my current post

I am using below code

<?php $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
}
?>

The output is

Post_tag : 1024x768

Post_tag : pics

Post_tag : india

Post_tag : 1366x768

Post_tag : 1920x1080

Post_tag : 1920x1200

Post_tag : 2015

Post_tag : 3d

But it shows list of all tags and i want to list tags which is related with Post ID = 17

marked as duplicate by Pieter Goosen, TheDeadMedic, Howdy_McGee, Sisir, Mayeenul Islam Aug 31 '15 at 8:08

This question was marked as an exact duplicate of an existing question.

  • how to show tags where Post ID = 17 – user3762572 Aug 23 '15 at 19:07
0

Can't you just use this:

<?php the_tags( '<span class="tags">', ', ', '</span>' ); ?>

https://codex.wordpress.org/Function_Reference/the_tags

get_terms gives you all the tags from your site I think.

  • I already tried it but it is not showing any result, may be because i am using custom page and my post id is stored in $postid variable and wherever i need postid i am using this veriable. is there any way to use the_tags() with custom postid veriable. – user3762572 Aug 24 '15 at 5:14
  • Uff.. Don't know about that. I'm not an expert either. But in short future this will be interesting for me too. – ezkay Aug 25 '15 at 12:36

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