Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How do i output images from URL’s added to the same custom field key

Since you are storing an url for each image you can create a query to get the id of the attachment based on the guid:

global $wpdb;
$ids = array();
foreach ($images as $image_url) {
  $ids[] = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url));
}

Another way would be to simply store the ID rather than the url in your custom field, then there would not be necessary to perform a the above query for each image.

Related Posts:

  1. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  2. Is it possible to store arrays in a custom field?
  3. Get specific custom field keys from a post and put into an array
  4. Run a check for multiple meta key values
  5. change order of images attached to post
  6. Build Array from Input Fields question
  7. Can I exclude a post by meta key using pre_get_posts function?
  8. Custom post meta field effect on the performance on the post
  9. How to get custom post meta using REST API
  10. Difference between meta keys with _ and without _ [duplicate]
  11. Orderby meta_value only returns posts that have existing meta_key
  12. What is the index [0] for on post meta fields?
  13. What is “meta_input” parameter in wp_insert_post() used for?
  14. How to enable revisions for post meta data?
  15. The “_encloseme” Meta-Key Conundrum
  16. Best way to programmatically remove a category/term from a post
  17. Using get_post_meta with new_to_publish
  18. Can I query custom meta data through WP_Query
  19. Custom field metabox not showing in back-end
  20. So much data in postmeta
  21. Can I count the number of users matching a value in a multiple value key?
  22. How to hide meta box values from custom fields list?
  23. Auto sort the wp-admin post list by a meta key
  24. WP doesn’t show Array Custom Fields?
  25. get_post_meta() unserialize issue – returns boolean(false)
  26. What is the advantage of the wp_options design pattern?
  27. Storing meta fields multiple times OR once with multi dimensional array?
  28. Allow user to create instances of custom field
  29. display specific custom fields
  30. How do I search an array stored in a custom-field using WP_Query?
  31. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  32. Meta keywords and descriptions plugin for manually editing meta for each page/post
  33. passing argument to get_template_part() or a better way to code
  34. Get updated meta data after save_post hook
  35. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  36. Save HTML formatted data to post meta using add_post_meta()
  37. importing data from non-wordpress mysql db
  38. Create meta boxes that don’t show in custom fields
  39. Transients vs CRON +Custom Fields: Caching Data Per Post
  40. Unable to save datetime custom meta field using update_post_meta() function
  41. Up/Down voting system for WordPress
  42. post meta data clearing on autosave
  43. Create custom field on post draft or publish?
  44. Display info from custom fields in all images’ HTML
  45. Ordering posts by anniversary using only day and month
  46. get_post_meta fields don’t show up on posts page
  47. Update meta values with AJAX
  48. How to break meta values into different items and avoid duplicates?
  49. use get_posts to get custom field data, but in one array
  50. copy attachments to another post type and change attachment url
  51. Cannot edit post meta fields with rest API
  52. ajax delete value from custom field array
  53. Save attachment custom fields on front end
  54. How to use pagination with get_post_meta
  55. Copying Custom Meta Values from existing post to a duplicate post
  56. Add a post meta key and value only if it does not exist on the post
  57. Saving an array in a single custom field
  58. Move value of one custom field to another
  59. Order posts according to user defined order for meta values?
  60. Displaying posts with only upcoming dates according their custom field date value
  61. Custom fields to save multiple values
  62. Custom fields: In what order are they saved into the DB?
  63. Function to change meta value in database for each post
  64. Get a post_id where meta_value equals something in a serialized meta_value field
  65. Get aggregate list of all custom fields for entire blog
  66. Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
  67. Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
  68. Custom field value based on other custom field values
  69. wp_handle_upload error “Specified file failed upload test” but still creates attachment?
  70. How to save a ToggleControl value in a meta field?
  71. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  72. Saving custom image meta fields
  73. Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
  74. How to display Meta Field Value?
  75. MySQL query to set wp_postmeta using term_taxonomy_id value
  76. How to Validate Post Meta type/extension (Video File Image File etc)
  77. Get all meta keys assigned to a post type
  78. using multiple meta_key and meta_value in query_posts
  79. Custom Meta Box not Saving in Posts with Gutenberg Editor
  80. Adding custom fields (post meta) before/during wp_insert_post()
  81. Combine multiple custom field values into single value
  82. How can I sort homepage by a meta value?
  83. WP Query Returning All Posts
  84. How do I use wp_query for WordPress search?
  85. Nav Menu – Add class based on meta keys
  86. Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)
  87. How to query posts with certain custom meta data, and output Post data
  88. MySQL Query that looks for post with Custom Field, then changes Category
  89. ACF: How to get the full field name (meta_key) by a field key?
  90. How to wrap meta values seperated by comma in ? [closed]
  91. Bulk remove post meta
  92. post meta getting deleted on save
  93. How to create html block to display extra information on woocommerce single product page
  94. Can’t get post ID using wp_insert_post_data
  95. Unique Post Meta Values
  96. Create Multiple File Upload Metabox in WordPress
  97. filtering custom post types via meta data drop down
  98. How to add a new meta key and assign timestamp to posts
  99. If meta key exists in get posts function otherwise create it
  100. Create an Array of Specific Custom Post Meta
Categories custom-field Tags array, custom-field, post-meta
My understrap-child theme doesent have a head.php, footer.php
I can’t install theme: theme install failed

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress