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 Retrieve An Image Attachment’s Alt Text?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- Meta compare with date (stored as string) not working
- Insert an image into a post by API
- How to update/insert custom field(post meta) data with wordpress REST API?
- Separate attachment images from post loop
- Front-end update_post_meta snippet displays white screen?
- Clean up output added via wp_head()
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- Is there a way to get attachment data?
- How to get custom post type to display post meta on archive pages?
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How to use post_id with a Class?
- get the image of the post
- Set default Custom Post Meta Value
- Adding width and height to wp_get_attachment_image_src
- List all images from a single post meta value
- INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Set Checkbox as checked by default
- Load post attached images on a single page site with fancybox
- Out of memory error reporting
- Exclude images from “inserted into post” when trying to get attachments
- replacing the_autor or make callback
- Link Attachment Image to Category
- Display images that are not in the content
- Some post meta fields stop saving after a few successful saves
- Check what attached image size is used
- Update attachment metadata fails
- Images attached to posts from library link to 404 error page
- Add Embed.ly API objects to post_meta on update
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- How to selected which tags to print, instead of printing the whole tag list?
- query posts and split meta information into separate div’s
- Getting Different Size Of Attachment Images
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- Get images attached to a specific page
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- wordpress is_front_page() issue
- update_post_meta not working?
- Change wordpress meta tag description using WP functions
- How to replace post image url before posting using api?
- Cant create or update meta fields using WordPress REST API
- Filter posts by meta key
- Display current ranking of post as a number in post title
- Post Thumbnail missing when using webp format while sharing
- Bulk Update Post Meta Values from Different Post via Rest Api
- Auto delete content in specific folder inside media library
- update_post_meta() is not saving the value
- Only show meta on one post type on search results page
- How to register post meta with multi level arrays?
- How to update an image attachment’s alt text from a custom field when saving a post?
- How to echo images Urls from a wordpress post, that are relally in the post
- If I disable screen options, does WP still try to update post meta?
- I created a Custom Meta Box but it is not displaying the value on my post page
- Allow users to upload attachments to certain posts
- Meta data being pulled from wp-login.php
- Get post content before rendering
- wp_insert_post inside save_post adds wrong metadata to inserted post
- Rename image filename using ‘media_handle_upload’
- Update Post metafield of specific categories
- Using Self Hosted Video URL With Custom Fields
- Multiple postmeta values to the same post_id/meta_key combination?
- get_post_meta not work in php foreach
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Performace on 1 million plus meta fields vs 1 field with 1 million multi array
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- how to echo/display the custom field value in specific custom field name?
- Create a custom attachment thumbnail for quick page load
- update_post_meta() not working in bulk option
- How can I hide previous_image_link() on first attachment page?
- Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
- delete attachment for one post without deleting actual attachment post
- get_children filter with postmeta
- wordpress query making site very slow
- if condition from post_meta not working in save_post