Http-Access Zirkus:imPark
I am trying to:
use the movedo gallery by placing the id from the related images "artisten-fotos" via the shortcode "get-image-ids".
[movedo_gallery ids="[get-image-ids]" gallery_mode="masonry"][/movedo_gallery]
The shortcode works see: 1. This are the ids from the post by the shortcode „get-image-ids“ at hidden link
Thats my code in the function.php for the short "code get-image.ids" like discribed at https://toolset.com/forums/topic/get-id-of-repeater-image-field-insted-of-url/:
function prefix_get_img_ids($atts) {
global $post;
$images = (array) get_post_meta($post->ID, 'wpcf-artisten-fotos', 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");
Thats my Template for Artisten:
[vc_row][vc_column][vc_column_text]
<h1>[wpv-post-title]</h1>
[wpv-post-body view_template="None"][/vc_column_text][/vc_column][/vc_row]
[vc_row][vc_column][movedo_video video_link="[types field='artisten-video-link' output='raw'][/types]"][/vc_column][/vc_row]
[vc_row][vc_column]<strong>1. This are the ids from the post by the shortcode "get-image-ids"</strong><br/>[get-image-ids][/vc_column][/vc_row]
[vc_row][vc_column]<strong>2. This is the movedo gallery trying to place the id's with the shortcode "get-image-ids"</strong><br/>[movedo_gallery ids="[get-image-ids]" gallery_mode="masonry"][/movedo_gallery][/vc_column][/vc_row]
[vc_row][vc_column]<strong>3. This is the movedo gallery how it should look, with ids copy pasted from the shortcode output</strong><br/>[movedo_gallery ids="147,148,150,151" gallery_mode="masonry"][/movedo_gallery][/vc_column][/vc_row]
Link to a page where the issue can be seen:
hidden link
The Galleries and infos are under the video
I expected to see:
see: 3. This is the movedo gallery how it should look, with ids copy pasted from the shortcode output
Instead, I got:
see: 2. This is the movedo gallery trying to place the id’s with the shortcode "get-image-ids"
Hi Torsten,
Thank you for waiting.
The WordPress shortcodes API doesn't officially support the use of square brackets ( [] ) or other shortcodes, as the attribute values.
( ref: https://codex.wordpress.org/Shortcode_API#Square_Brackets )
Note: Toolset's own shortcodes are an exception because they're rendered with some extra processing.
To overcome this limitation, you have a couple of options:
1. You can create a new custom shortcode, that can first get the IDs through the "get-image-ids" shortcode and then set them as a comma-separated string in the "movedo_gallery shortcode and then return the output after processing.
( ref: https://developer.wordpress.org/reference/functions/do_shortcode/ )
2. If option 1 doesn't work, you can consult the "Movedo Extension" plugin's support team, for further suggestions or workarounds around how their gallery shortcode works.
regards,
Waqar