Skip Navigation

[Resolved] Need to get two loop items to work inside a view

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.

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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 1 year, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2561045

Tell us what you are trying to do? I have a dropdown sort by Region. When someone chooses a region, I want to show a list of bicycle trails followed by a list of businesses, each with a header. It ends up showing them all weaved together, though, instead of separate lists.

Is there any documentation that you are following? I searched the support tickets and also read this: https://toolset.com/documentation/legacy-features/views-plugin/digging-into-view-outputs/

Is there a similar example that we can see?

What is the link to your site? hidden link

#2561485

So I did get this to *almost* work. All I need is for each of the custom post type sections to have a heading. The list is sorted by post type, but I'm not sure how to get a label for each post type inserted. Maybe code?

#2562175

Hello,

How do you setup the post view and view's loop? Can you take a screenshot for it?

In single post, you can display it's post type value with shortcode [wpv-post-type], see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-type

#2562435

It's possible there's a better way for me to be doing this, but I have the taxonomy results sorted first by post type and then alphabetically. I have it so that if the post type is one thing, it formats a certain way, and if it's the other post type, it formats a different way. But I don't know where to put the post type name so that it only appears once.

Loop:

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-post-body view_template="loop-item-in-trails-by-region"]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

Loop item:

[wpv-conditional if="( $(wpcf-contact-phone-number) ne '' )"][wpv-post-link]
<div class="trail-row">[wpv-post-excerpt]
[wpv-post-featured-image size="large"]
[wpv-post-excerpt output="raw"]</div>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-address-business) ne '' )"]
<div class="business-row"><div class="business-name"><a href="[types field='business-website' output='raw'][/types]" target="_blank" rel="noopener">[wpv-post-title]<i class="fa fa-external-link" aria-hidden="true" style="margin-left:5px;"></a></div><div class="business-address">[types field='address-business'][/types]</div><div class="business-phone">[types field='business-phone-number'][/types]</div></div>
[/wpv-conditional]

#2562733

There isn't such kind of built-in feature, as I mentioned above:
shortcode [wpv-post-type] works in single post.

In your case, you might consider two post views, each post view query only one post type, and filter by the same taxonomy URL parameter, so you can add the section head manually before the post view shortcode, for example:

Post type A:
[wpv-view name="view-1"]
Post type B:
[wpv-view name="view-2"]

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