I've been trying to echo some text to all single pages that are part of tag_ID 129

This is the code that I used


if ( is_tag( '129' )){

echo '<p> test 2</p>';

so far no luck.. The image attached is too show where I'm getting the info

any help would be great! thanks


enter image description here

1 Answer 1


That's not what is_tag does:

Determines whether the query is for an existing tag archive page.


is_tag and other functions such as is_search etc don't tell you anything about a post, they tell you if you're on a search archive, or a tag archive, etc

So is_tag is true on example.com/tag/example but would be false on a post because that's not a tag archive.

Instead what you want, is has_tag https://developer.wordpress.org/reference/functions/has_tag/

Some final notes though:

  • Don't hardcode term IDs! Use the slug/name if you really have to hardcode things. If you ever delete that tag by accident, or have to do a migration, your code would stop working.
  • Indent your code, it'll avoid entire types of bugs, and make it easier to read ( especially for people who might answer questions :p )
  • If in doubt, check the official docs at https://developer.wordpress.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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