You should reorganize the way you store the images: Make the uploaded files children of that particular post, do not put them in a post meta field. Then get all the images with get_children()
. Look at the built-in handler for the shortcode for some examples.
I should go like this:
$args = array(
'post_mime_type' => 'image',
'numberposts' => -1,
'post_parent' => get_the_ID(),
'post_type' => 'attachment'
);
$attached_images = get_children( $args );
foreach ( $attached_images as $image )
{
// print image
}
And even if you want to stay with post meta fields, do not store URLs, use the attachment IDs instead. URLs can change any time (think about a migration from dev to production site).
Related Posts:
- How to get source of custom meta image?
- copy images from custom field to another custom field
- what is the correct way to compare dates in a WP query_posts meta_query
- Advanced search form with filters for custom taxonomies and custom fields
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- How do I Paginate Search Results for Custom Post Types?
- How Can I save multiple records in same meta key?
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- Stopping WordPress from Auto Generating Image Files for Sizes
- Displaying Meta Box Image
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Create a random unique 6 digit number as custom field for custom post type
- how to interconnect custom post types?
- Populate Custom Fields in a Custom Post Type?
- Meta Key Value in current-user-only loop
- How to check if user meta field is empty in conditional else statement
- Get image post ID in media upload
- How to implement a Google map store locator
- Posting to a Custom Post Type from front end – user generated content
- Update Post Meta for a logged in user
- A better way to add a meta box to custom post types
- Two Custom Post Types Many to Many Relationship
- get_post_meta not working on publishing
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- frontend image post uploader
- Importing Data from a Non-WordPress database, into WP
- Custom fields for custom post type
- Check if post with same meta value exists
- Submitting Custom Post Types with custom fields from Front-end form
- create custom meta box with default value
- delete_post_meta() for whole CPT / multiple posts?
- How to get specific post meta by title or id
- How do you output an unknown number of images in a custom post type with desired markup?
- How to show custom field on specific custom post type posts only when filled
- Cannot obtain custom meta information
- How can I output WPAlchemy repeating fields meta values in my page template?
- How to call a post’s metadata in shortcode.php?
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- updating one custom meta field only
- Add a class to post_class if more than one post shares same meta_value_num
- Add a meta field to the list of results for a custom post type
- Should i use custom post type for a custom footer?
- Empty meta-box returns publishdate if no value is set?
- Filter search posts by post meta?
- Custom fields for post or terms which don’t update on post update
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to keep custom post type related information
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Where is get_post_meta value located?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Change picture attachment meta of all occurrences of a picture
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Add more custom fields when creating a new custom post type
- How do I extract the contents of a CPT’s custom field for all posts?
- Delete custom post type metadata without deleting the post in admin area
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- How to add post reference field to a plugin?
- Advanced search form with filters for custom taxonomies and custom fields
- Retrieve post data via WPDB class
- Querying meta values within an array
- How to Create a Frontend Html-list Editable in the Backend?
- Allow authors to create article image
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Check for custom field value in different post type than current one and do something
- Thumbnails Not Generating
- Excerpt length: get first paragraph
- Get post-meta value of all custom-posts – lowest to highest year-count?
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Function to return values from metabox
- How to get custom image field of specific post id
- How to keep a record of changes to a custom field?
- Fill custom fields when saving custom post types
- Making a form for user to add new custom post with custom taxonomies and custom fields
- best way to use custom taxonomy, post type and meta in a job system
- Order custom posts by taxonomy, then by meta_key
- Adding a Custom Field to be used by Posts 2 Posts
- Custom field only on custom post type?
- Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
- Returning an image url from its attachment ID using a custom post type plugin
- Saving metabox keys and storing values as array
- Custom PT, Taxonomys and wordpress query
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Front-end Image Upload to Custom Meta Box
- Building tags and archive using meta from custom post type
- How do I list a custom field and custom taxonomies for each result in a loop?
- How to order custom posts by one of the custom fields value, ‘date’?
- Writing a custom Glossary plugin