I am testing several frameworks (currently Vafpress) to help me creating custom meta boxes. I need to save a lot of attachments with my posts but noticed that the attachment is saved with its full URL, not the ID.

  1. There seems to be no "easy" way to get full data (title, desc, date) from an attachment, when I only have the URL, right?
  2. Is there any framework that saves ID instead of the URL?
  3. Any other suggestions to save attachments, maybe without a custom meta box?
  • Did you try to use get_attachment_id() function from Rarst?
    – Sven
    Mar 23 '14 at 13:15
  • This seems very specific to that particular framework. That would make this question off-topic.
    – s_ha_dum
    Mar 23 '14 at 13:50
  • Have seen this in all tested frameworks/classes
    – suntrop
    Mar 23 '14 at 14:42
  • @suntrop assuming all frameworks/classes do same thing, most probably each do it in different framework specific way. So it's impossible to post an answer that's is good for all.
    – gmazzap
    Mar 23 '14 at 17:16
  • OK, I'll try another way to get my things done.
    – suntrop
    Mar 24 '14 at 16:27

At some point in the process you could do the following:

  1. Generate attachment ID from URL, like here
  2. Save attachment ID to custom field value using add_post_meta()
  3. Retrieve attachment using custom field value later with get_post_meta()

Your Answer

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

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