I have created a model and it works quite well.
I have two requests for information ... I hope I can explain myself well.
1. I can't delete the first part of default (I attach image)
hidden link
2. I have created a gallery field and would like to use a WPBakery Page Builder tool. This shortcode wants past images with this syntax: include = "5210.5213.5212.5211.5214.5209". How can I insert the data of the toolset field in the shortcode
thanks
federico
Dear federico,
Q1) According to your screenshot, those should be:
- Post title
- Post featured image.
It depends on your theme file, Toolset content template works only in post content area, it seems you are using a child theme of "allston", you will find and locate theme files for "Post title" and "Post featured image", and customize as what you want.
In most cases, you can create a new theme file single-{post-type}.php in the child theme folder, and customize it. see WordPress document:
https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
single-{post-type}.php – If the post type is product, WordPress would look for single-product.php.
Q2) How do you setup the "gallery field", if it is a custom repeating image field:
https://toolset.com/documentation/user-guides/custom-content/repeating-fields/
Since Toolset repeating image field save image's URL in database, you will need to setup custom codes to turn the image URLs into attachment IDs, for example, there is a similar thread:
https://toolset.com/forums/topic/display-image-ids-for-repeating-image-field/
For your reference.
almost solved everything like this:
in functions.php I added:
add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
global $post, $wpdb;
$images = get_post_meta($post->ID, 'wpcf-gallery', false);
$ids = array();
foreach ($images as $image) {
$attachment_id = $wpdb->get_var($wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid = %s",
$image
));
$ids[] = $attachment_id;
}
$out = do_shortcode('[gallery ids="' . implode(",", $ids) . '"]');
return $out;
}
there is one thing I don't understand (probably because of me). if at the end of the function I insert the shortcode that interests me like this:
$out=do_shortcode('[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="' . implode(",", $ids) . '" el_class=".gallery-prod"]');
I don't see the gallery on the product page, (I added in view [repeating_images_gallery_func]).
if instead I insert the code in the view:
[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="5210,5213,5212,5211,5214,5209" el_class=".gallery-prod"]
the gallery works.
shouldn't it be the same?
thanks
It is a custom codes problem, please provide a test site with the same problem, also point out the problem page URL and where I can edit your PHP codes, I need to test and debug it in a live website. Thanks
Thanks for the details, I have done below modifications in your website:
1) Change the PHP codes as below:
add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
global $post, $wpdb;
$images = get_post_meta($post->ID, 'wpcf-gallery', false);
$ids = array();
foreach ($images as $image) {
$attachment_id = $wpdb->get_var($wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid = %s",
$image
));
$ids[] = $attachment_id;
}
$res = implode(',', $ids);
//$out=do_shortcode('[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582759842872-f01f8d3b-a78e-1" include="5214,5209" el_class=".gallery-prod"][vc_media_grid element_width="6" gap="35" grid_id="vc_gid:1582759860998-d8827e1a-8297-4" include="' . $str . '"]');
return $res;
}
So the shortcode [repeating-images-gallery] will output the attachment IDs
2) Edit the content template, use above custom shortcode as below:
[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="[repeating-images-gallery]" el_class=".gallery-prod"]
3) Dashborad-> Toolset-> Settings-> Contenuto del front-end
In section "Argomenti degli shortcode di terze parti", add the shortcode name: repeating-images-gallery
Please test it again, check if it is fixed, thanks
there were changes that I had tried too but the shortcode is not loaded well:
hidden link
Thanks for the details, I can see the problem you mentioned above
Please test the shortcode directly:
[repeating-images-gallery]
You should be able to see it does outputs the attachment IDs correctly:
hidden link
But the problem is shortcode [vc_masonry_media_grid] does not support using other shortcode as attribute "include", you might need to check it with author of shortcode [vc_masonry_media_grid], how to pass other shortcode values to that shortcode.
I tried using the toolset plugin block for viewing photos in masonry
hidden link
but I can't find the way to view the images completely and only 2 images per row.
I solved by redoing the whole single page
My issue is resolved now. Thank you!