Your var_dump looks like it’s returning an array because you’re passing false to get_post_meta(). Also you don’t want to print_r() on an echo line.
Retrieve post meta field for a post.
- $post_id (int) (Required) Post ID.
- $key (string) (Optional) The meta key to retrieve. By default, returns data for all keys. Default value: ”
- $single (bool) (Optional) Whether to return a single value. Default value: false
<?php
$ppics = get_post_meta( get_the_ID(), 'shop_demosc', true );
// if the value is an array of an array, just set to the first array
if( is_array($ppics) && count($ppics) === 1 && is_array($ppics[0]) ){
$ppics = $ppics[0];
}
foreach ( $ppics as $key => $attachment_id ) {
$image_url = wp_get_attachment_url( $attachment_id );
printf( '<img src="https://wordpress.stackexchange.com/questions/245405/%s">', $image_url );
}
?>
Related Posts:
- How to get meta value in wp_attachment_metadata
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- Display info from custom fields in all images’ HTML
- copy attachments to another post type and change attachment url
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- Adding meta data to an attachment post
- Regenerate missing _wp_attachment_metadata
- How to change ID of an attachment in wp_posts and its related tables correctly?
- echo image caption
- get_post_meta not working on category.php
- What are the meta fields for an attachment?
- How does WordPress treats attachments metadata in post content?
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Attachment metadata has value of ‘1’
- Create a Gallery and update Post Parent of Attachment Images
- How to append $metadata[‘sizes’] to metadata when using ‘wp_generate_attachment_metadata?
- Can I attach image to post without adding it to post?
- Remove Dimension from wp_get_attachment_image
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- How get post id from meta value
- Safe to delete blank postmeta?
- Applying automatic link class to images embedded to posts
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- How to set author for post AND post attachments
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Should I sanitize custom post meta if it is going to be escaped later?
- Making images from single.php pointing to an attachment .php template
- Query between two meta values?
- copy attachment title to description and alt text
- List posts under meta_value heading
- wp_get_attachment_image_src always returns false
- Exact image sizes
- Change default URL of image attachment
- Get the size (size in Kb or MB) of an featured image?
- Regex to turn embedded images in to attachments
- Saving html into postmeta without stripping tags – safe?
- How to show Published date and/or Modified date
- wp_update_user isn’t instantly?
- media_sideload_image with rewritten urls?
- Get the bare URL for an attachment
- Get thumbnail url of custom meta image?
- Exclude featured image from attachment loop
- How to use update_post_meta inside wp_trash_post
- Display All Custom Post Fields and Values, Unless Empty
- Dynamic tagged image galleries
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- How to create a meta_query to get all posts with a specific meta data?
- Help to upload post attachments from Ajax
- Post MetaTable Overload
- Custom RSS Feeds & Post Meta Data
- get_post_meta not extracting title,permalink and posttype
- Display get_post_meta if contains value
- Save post meta foreach loop
- Should I save this mulit dementional arary as one post meta?
- How do you import images from a URL in your post?
- Sort Posts By Custom Field Date?
- Difficultly changing date format in post meta value
- Remove last character in get_post_meta
- Uploaded attachment not set as featured image
- mass delete posts based on metadata
- How to obtain a group of post meta and assign each meta to other variables?
- Duplicate rows in meta table, any known relations in WC?
- Suggestion to make posts have multiple associated items
- update_post_meta in loop changing ALL values
- show ad after # paragraphs
- Image not showing using a custom function and get_post_meta
- How we can get “get_post_meta” of specific user who added it
- Randomizing Post Links Outside of Loop – No Author or Date
- Excluding post thumbnail from the attachment.php when using wordpress gallery
- help to decipher wp metadata
- SQL query – get a featured image’s alt / alternative text
- I can not display meta value in extras.php and template-tags.php
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- Sorting my posts on homepage my specific value in post_meta table
- Check if any meta on the post has value then display content
- SQL: How to find all attachments that are not used in any posts/pages/custom_post_types
- Combine meta query and give a specific meta query a higher priority
- How can i show post views using specified post ID?
- gettext localization is not working
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- How to sort by meta value num, but ignore zero value?
- Update event post meta each day automaticaly
- Advanced Custom Field — grabbing post_meta from previous post
- Issue on Getting WP Gallery Items In cpt-single.php As Attachments
- How to create a link for wordpress meta datas?
- Which query method to use? (edit- wpdb syntax problems)
- Upload unnattached image from frontend
- Image attachement management – a philosophical question
- wp_get_attachment_link() add rel attribute if the link points to direct image
- wp_postmeta store multiple values in one key [closed]
- How to link images of one WP site to another WP site?
- Save frontend submission form field as custom field
- Broken images after importing posts and opening in Gutenberg
- Define how an attached image is rendered
- Hide individual page title using checkbox in custom meta box?
- Footnotes are not copied as a block