Skip Navigation

[Resolved] Not able to display multiple post values when running a loop

This support ticket is created 3 years, 7 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 9 replies, has 4 voices.

Last updated by AlimB3245 3 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#1785569
Screen Shot 2020-09-22 at 5.48.35 PM.png

Tell us what you are trying to do?

This query is connected to this ticket and is an extension
https://toolset.com/forums/topic/a-code-that-works-on-its-own-does-not-display-when-looped-in-a-view-2/#post-1785421

So now I am able to loop through the brand distributor of the eyewear collection as well as display it as a short code.. this is perfect.. but now the reason I was looping and not displaying using the short code is because I have multiple brand distributors in the relationship.. one brand can have multiple brand distributors.. so when an eyewear collection is looking for a grand parent, I expected to display multiple grand parents.. but I am able to see just one even when I loop.

Here's the link to the Eyewear Collection Profile Page
hidden link

this displays on the left side the short code views as well as the loop views and is self-explanatory

Why does it not display multiple brand distributors when I am looping? In the previous ticket I was asked to remove this code
[wpv-item index=other]

Please do advise how I can display the two brand distributors that are connected to the brand.. Here's the screenshot of the relationship

https://toolset.com/wp-content/uploads/tmp/Screen_Shot_2020_09_22_at_5.48.35_PM.png

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

#1786553

Hi, may I log in and see how the View and filters are set up? The screenshot here isn't working and the login credentials in previous tickets are removed for your security when a ticket is resolved. I think it will be fastest for me to see things in wp-admin.

#1787985

I'm looking at the View now, and I can see that it has a Post Relationship Query Filter set up as shown in the screenshot here. You can see the filter is set with the configuration "Select items in the Brand Distributors To Eyewear Brands relationship as related items of the post where this View is shown". However, the View is not shown on a Brand Distributors post. Instead, it is shown in an Eyewear Collection post, so the context is not quite right. You must edit this View:
hidden link
Change the Query Filter for post relationships. It should be reconfigured to respond to a shortcode attribute like wpvrelatedto. Then you must pass in the related Eyewear Brand post ID using a nested wpv-post-id shortcode. Since there can be only one Eyewear Brand related to the current Eyewear Collection, the correct syntax looks like this:

[wpv-view name="related-brand-distributor-eyewear-collection-brand-distributor-id" wpvrelatedto="[wpv-post-id item='@eyewear-brand-eyewear-collection.parent']"]

Please adjust the Query Filter in the View, then update the shortcode used to display the View as shown here, and let me know if you do not see both related Brand Distributors appear in the results of the View.

#1787987

Sorry I made a mistake in my previous comment. The correct View to edit is this one:
hidden link

#1790019
Screen Shot 2020-09-25 at 2.34.18 PM.png

Hi Christian

Thanks for the update.. :-)..

I tried as you mentioned and now in this content template for Eyewear Collections

hidden link

I have this code

[wpv-view name="related-brand-distributor-eyewear-collection-brand-distributor-id" wpvrelatedto="[wpv-post-id item='@eyewear-brand-eyewear-collection.parent']"]

And even this view (link below) was updated as per screenshot (https://toolset.com/wp-content/uploads/tmp/Screen_Shot_2020_09_25_at_2.34.18_PM.png)

hidden link

But on the frontend I get this response (No Items Found)

hidden link

What am I doing wrong?

Regards,
Alim

#1794537

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alim,

Christian is currently on vacation at the moment so I will be handling this ticket here.

I noticed that i'm not able to properly test this because any changes made to this template here
hidden link

Is not being reflected on the frontend because the frontend link is being redirected to this link below.
hidden link

As you can see both website url's are different so I will need to do the checks on the live site unless you can set the fourplusmedia.com site to not redirect the frontend to youandeyemag.com

Thanks,
Shane

#1794833

Hi Shane

Can you please transfer this ticket to Luo? He knows the history of this ticket and it would be easier for him to follow my requirement .. also he happens to be in a similar timezone as me so it would be really quicker.

Thanks in advance. Have a nice day..:-)..

Regards,
Alim

#1796049

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alim,

I've reassigned this ticket to Luo.

#1797561

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alim,

Luo will be on vacation for the entire next week, so I hope that's ok with you if I follow-up on this ticket.

I've reviewed your view "Related Brand Distributor Eyewear Collection Brand Distributor ID" ( ID: 46733 ) and noticed that it needed the following adjustments.

1. In the content selection settings "Eyewear Brands" post type was selected, when the objective of this view is to show "Brand Owners".

2. In the query filter section, the relationship "Eyewear Brands To Eyewear Collections" was selected, when the correct relationship, in this case, would be "Brand Distributors To Eyewear Brands".

3. In the loop editor section, the fields were set to show with the "item" attribute setting the scope to parent, when it is not needed as the loop is directly of the "Brand Owners" posts.

Old code:


[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>ID: [types field="id" item="@brand-distributor-eyewear-brand.parent" output="raw"][/types]<br/>Name : [wpv-post-title item="@brand-distributor-eyewear-brand.parent" output="raw"]<br/>Email : [types field="notification-email" item="@brand-distributor-eyewear-brand.parent" separator="," output="raw"][/types]<br/>Mobile : [types field="notification-mobile" item="@brand-distributor-eyewear-brand.parent" output="raw"][/types]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][wpv-layout-end]

Updated code:


[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>ID: [types field="id" output="raw"][/types]<br/>Name : [wpv-post-title output="raw"]<br/>Email : [types field="notification-email" separator="," output="raw"][/types]<br/>Mobile : [types field="notification-mobile" output="raw"][/types]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][wpv-layout-end]

Now if you'll check the "Chopard Men’s Eyewear Collection Spring/Summer 2020" post, you'll see information from both distributors, under "Displayed as a result of loop from View".
( ref: hidden link )

regards,
Waqar

#1799305

Thanks Waqar,

It was a complicated ticket but you made it look so simple!!!..;-)..

Thanks again.. it works perfect!!

Regards,
Alim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.