This support ticket is created 3 years, 2 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.
hidden link
Hello
In this slider there is only one image and it is repeated 3 times in the thumbnail bar.
How to display only the image, this is an exception in the set of book sliders. I didn't manage to produce the shortcode with if
Can you help me
Thank you
Hello and thank you for contacting the Toolset support.
I assume that you have configured the Slider to have 3 items per page, right?
It will always have 3 items per page. For example, if the post has only two images, the first one will be duplicated as being the 3rd.
If you want to handle the case of fewer than 3 images, I'll suggest that you wrap the slider inside a conditional block that will check the count of images. If you have only one image, display an Image block instead of the slider. If you have 2 images display a Slider with 2 items. And if you have 3 or more images display the current Slider.
Would you allow me temporary access to check this further? I will also need FTP access to recover the functions.php file if the code breaks the site. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
I did not spot the issue with the code yesterday. The code has a mistake. The function name should be "my_count_repeatable_field" with an underscore before "field" instead of "my_count_repeatable field". Final code after adapting the field slug below:
function my_count_repeatable_field() {
global $post;
$field_slug = 'livre-images';
return sizeof(get_post_meta( $post->ID, 'wpcf-' . $field_slug, false ));
}
I added the code to Toolset->Settings->Custom code and registered the function in Toolset Settings. Then I built three conditional blocks with the function:
- When there is only one image. I put an Image block inside of it.
- When there are two images. I put a new slider with two thumbnails inside of it.
- When there 3 or more images. I moved the existing slider into it.
The existing slider is displayed for this post that has 4 images hidden link
The Image block is displayed for this post, that did not have an image, and where I added the featured image in the custom field too hidden link
I'll let you check for a post that has only 2 images in the field, it should display a slider with two thumbnails similar to this preview hidden link