Skip Navigation

[Resolved] View not pulling repeatable image from current page

This support ticket is created 4 years, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1536571
Screen-Shot-2020-03-02-at-5.32.06-PM.jpg
Screen Shot 2020-03-02 at 5.31.53 PM.png

I have built a layout for a custom post type that you can see here:

hidden link

In the layout I have created views to show images associated with the page. The images come form a field of "repeatable images."

When I created the view I used something like this for the loop:

Example of the "image1, image2, image3" section:

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<div class="full-viewport">
<div class="work-image2">
[types field="portfolio" index="0" item="$current_page"][/types]
</div>
<div class="work-image3">
[types field="portfolio" index="1" item="$current_page"][/types]
</div>
<div class="work-image4">
[types field="portfolio" index="2" item="$current_page"][/types]
</div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-layout-end]

The idea is that it would pull images form "portfolio" from the "current page" and it would pull them by the order set in the repeatable field.... there are several loops used... so that the content would display kind of in a magazine style.

I could just have individual image fields... but I thought it was more user friendly if I had one place for the client to upload the images at one time. That said... I can't get the page to show the right images on each page. Whatever I add/edit last... will be the image that is used in the loop. Regardless of the post it came from. (Hope that makes sense). So if I add page 13... the images are displayed on page 12. It does not recognize the repeatable image field from each page.

If what I want to do doesn't make sense, I can just switch to single image uploads... but not repeatable content.

I attached a screenshot of the images showing on "hidden link", and the images that are "really on that page." Notice how the "gray images... are not part of that page."

#1536803

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Based on the screenshot you shared - I see that you are using the repeating image field portfolio that holds that multiple images and you are using the view to display those repeating images using the specific index.

I'm not sure why you are using the view if you want to display the same page/post content of the single post to which Layout is assigned. I see that you are displaying single post of post type work and if the portfolio field belongs to that work post type then you should use the Visual Editor cell rather adding view:
=> https://toolset.com/documentation/user-guides/layouts/rich-content-cell-text-images-html/

And add the shortcode:

<div class="full-viewport">
<div class="work-image2">
[types field="portfolio" index="0" ][/types]
</div>
<div class="work-image3">
[types field="portfolio" index="1" ][/types]
</div>
<div class="work-image4">
[types field="portfolio" index="2"][/types]
</div>
</div>

Can you please check if the above information helps you to resolve your issue. Otherwise, you can send me temporary admin access details so I can review your current setup and guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1537553

Thank you for the help. It actually does work.

My main goal was to have the dynamic content from the repeatable field show in three separate areas on the page. So far that is working using the index feature. And that is why I had originally used views.

I have one thing I am still trying to figure out... I am trying to get the "remainder of the images" to loop... so that would mean I need to show items that are "greater than" index 7.

I have seen this code... but it doesn't work.

[types field="portfolio" index="other"]

#1538281

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It looks like you are mixing the index attribute here.

When you use the index attribute with Types shortcode, the value you pass to this index attribute should the index number of your repeating field instance. So, if you want to display the first instance of repeating field you need to use index=0.

[types field="portfolio" index="0"]

More info:
=> https://toolset.com/documentation/user-guides/custom-content/repeating-fields/#Index%20parameter%20Repeating%20Fields

Now, View's offers the shortcode [wpv-item] which also offers the index attribute, which you can use to display the specific view's loop index:
=> https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-item

Used in the loop. Sets a condition to be met for subsequent lines in the loop to be executed.
If the condition is true, the all subsequent lines will be executed until the next wpv-item shortcode encountered, or the end of the loop.

If you want to loop through the repeating field, you need to use the view's shortcode: [wpv-for-each]
=> https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-for-each

If you want to start and display the specific repeating field instance, you can use the start attribute. So following way, it will start to display the repeating field instance from 7th instance.

[wpv-for-each field="wpcf-portfolio" start="7"]
[types field="portfolio"][/types]
[/wpv-for-each]