[Resolved] Create WP gallery from multiple image field
This support ticket is created 7 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
function prefix_get_img_ids($atts) {
global $post;
$images = (array) get_post_meta($post->ID, 'wpcf-property-images', false); // cast to array in case there is only one item
$ids = array();
global $wpdb;
foreach($images as $img) {
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$img'";
$id = $wpdb->get_var($query);
$ids[] = $id;
}
return implode(",",$ids);
}
add_shortcode('get-image-ids', 'prefix_get_img_ids');
Using shortcode in template
[gallery ids="[get-image-ids]"]
This returns only “] in my single post.
Any idea why either of these approaches is not working? Thanks.