0

What I have Tried →

<?php
    $taginto = get_the_tag_list();
    if ( ! empty( $taginto ) ) {
    echo '<a class="categum" href="' . esc_url( get_tag_link( $taginto[0]->term_id ) ) . '">'  . esc_html( $taginto[0]->name ) . '</a>';
    }
?>

What I want →

I am on www.somedomain/tag/apple/ and trying to display all tags like this: there are some other tags that you can browse: tag list should follow(excluding the one on whose page we currently are.)

I am trying to display all the tags that exist, but miserably failed →

  1. tag list not getting fetched
  2. tags name not getting fetched

where am I wrong? what is the Fix?

  • 1
    Read the Codex page, get_the_tag_list returns a string, not an array of objects. You probably want something more like get_the_tags. – Milo Oct 5 '17 at 15:56
  • sir, I tried that also, but it is populating just one tag not all. If i am here → www.somedomain/tag/apple/ then it will print just "apple" – The WP Novice Oct 5 '17 at 16:00
  • 1
    If you want all tags, not just the ones attached to a specific post, use get_tags. The example on that codex page shows you how to use it, your code currently outputs just the first element of the returned array. – Milo Oct 5 '17 at 16:04
  • It worked for me. Will you write an answer? Is there any way we can exclude the one tag on whose page we are there.for example → www.somedomain/tag/apple/ apple should not be printed. – The WP Novice Oct 6 '17 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.