Skip Navigation

[Resolved] Trying to get images IDs to insert in a ux gallery

This support ticket is created 3 years, 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by melanieG-2 3 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#2101735

Trying to :
Insert image ID into a shortcode for UX gallery on Flatsome Theme

Is there any documentation that you are following?
Yes I read through the tickets talking about this issue and I followed this one : https://toolset.com/forums/topic/how-to-get-images-post-id-to-use-with-enfold-gallery/

Website: hidden link

What I did:

I added that code to my function.php file

function prefix_get_img_ids($atts) {
global $post;

$images = (array) get_post_meta($post->ID, 'wpcf-gallery', 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");

And then used those shortcodes:

[ux_gallery style="none" lightbox_image_size="original" type="masonry" columns="2" ids="[get-image-ids]"]
[gallery ids="[get-image-ids]" orderby="rand" columns="2" size="full" link="none"]

None of them are working (showing random pictures instead. See the result here: hidden link

However, the shortcode [get-image-ids] is working, I have the list of IDs showing up in the right format.
Did I do something wrong inserting the shortcode?

Thank you for your help!

#2101905

Hi,

Welcome to Toolset support and I'd be happy to assist.

To troubleshoot this, I'll need to see how this gallery page is set up in the admin area.

Can you please share temporary admin login details, in reply to his message?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#2103347

My issue is resolved now. Thank you!