WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get the custom field data off an attachment and display it following the image tag in a page/post using the get_image_tag filter.

I'm using the same function to get the same data and display it on the attachment field as well. That works perfectly using the the_content filter so I know the function is working ok and the data is being stored and retrieved.

I feel like I'm missing something really obvious. Based on the few other questions I can find about the get_image_tag filter, it seems like there's either something buggy about its implementation or it doesn't run where it seems like it should. I can't even get it to append a string to the resulting $html variable and I don't get an error with wp_debug = true either.

The code is on Pastebin at http://pastebin.com/VRcEyYBh.

share|improve this question
up vote 0 down vote accepted

Turned out my "answer" was that I didn't really understand "get_image_tag." It only runs when you first insert an image. I was thinking that it ran every time the edit interface was loaded.

From researching and talking with others, it seems the only way to get the metabox data onto existing images is some kind of regex on the database, probably adding a shortcode around imagines that don't have a caption and do have metabox values. Fun!

share|improve this answer

Your Answer


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.