This thread is resolved. Here is a description of the problem and solution.
Problem:
I am trying to pass a variable to the index='n' field when displaying an repeater image from a custom post type. I am using [incrementor] shortcode that returns the number in the view loop.
Solution:
I have registered [incrementor] shortcode in website and now it is working as expected.
Where [incrementor] is a shortcode that returns the number in the view loop. Using the shortcode doesn't work. I am either calling the shortcode function incorrectly, or this isn't possible this way.
Can you assist with a way to pass this view an index number.
Thank you for contacting Toolset Support. You can use repeating fields to display multiple images using the interface options of Toolset Types & Views, please see attached screenshot.
1. Can you please more clarify that why you want to achieve this using code? Or if I am not getting you right can you please provide step by step details that what you want to achieve? (preferably with back-end screenshots).
2. What you expected to see on the front page?
3. What you actually see right now (preferably with front-end screenshot or Link to page)?
Yes,
I have a CPT called 'posters' and one of the fields is a multi instance image field called 'poster artwork'.
I am trying to display all the products that the customer can purchase for this poster.
Each instance of this 'poster artwork' field contains an image of a mockup of what the poster will look like if purchased. (In order - main, poster medium, mug, poster small.)
The content template of the CPT 'posters' includes a view that shows all the woocommerce products associated to this type of poster.
I wish to display the 'poster artwork' in each instance of these products. Refer "Front end.jpg". As you can see, this is displaying the products perfectly, however, the index of the 'poster artwork' is static and not dynamic, and is only showing the same image.
I would have thought this would have been achieved by allowing the index='n' attribute of the field to be passed a variable. This does not work. This seems odd as id='n' attribute accepts a dynamic variable.
"Back end.jpg" shows my view displaying the products associated with Content Template of the CPT 'posters'.
As you can see, I'm using a shortcode called [incrementor] that simply counts the number of elements in the view. It produces the number next to the product in the "Front end.jpg"
I would have thought that I could put this [incrementor] into the "types field" line to achieve the result I'm hoping for...
This does not work:
[types field='poster-artwork' size='shop_catalog' align='none' resize='proportional' id='$current_page' index='[incrementor]'][/types]
My result will be achieved if the index attribute can accept a dynamic variable.
Thank you for providing details. I have understand your requirements now. The approach you are using is correct and I need to check its php code that what this [incrementor] shortcode is returning. So I need to request temporary access (WP-Admin and FTP Login info) to your site, if possible?
Your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please write the name or path of the file where this shortcode’s php code is placed (e.g. functions.php).
I can answer that quickly.
It is returning the number 'n' you see before the product title in the "Front end.jpg" - prior to "Poster - Medium", "Coffee Mug", "Poster - Small"
Just the number on each iteration of the product render.
Yes, the incrementor shortcode function appears in "functions.php" of the child theme folder.
Yes, I get that 🙂 But I like to take a look at the code and see what changes it need to get working. Can you please share temporary login access? I have enabled private message box.
I have debugged this issue and find the cause of the problem.
1. I have registered [incrementor] shortcode in your website and now it is working as expected. Please check here: hidden link
2. Basically to use custom shortcode, you need to register the shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments (see attached screenshot)