Skip Navigation

[Resolved] Can I confirm that THIS is the correct way to code the Views Loop

This support ticket is created 2 years, 8 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.

This topic contains 2 replies, has 2 voices.

Last updated by PaulS4783 2 years, 8 months ago.

Author
Posts
#2153235

Currently I have a taxonomy views loop that does this:

[wpv-layout-start]
    [wpv-items-found]
    <strong>Tickers:</strong>
    <!-- wpv-loop-start -->
    <wpv-loop>
        [wpv-post-body view_template="loop-item-in-ticker-terms"]
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    [/wpv-no-items-found]
[wpv-layout-end]

And the template "loop item in ticker terms" is simply this:

[wpv-taxonomy-link] /

The problem is that the last item in the loop always includes the trailing "/"

So I THINK this is the correct implementation. Could somebody check?

[wpv-layout-start]
    [wpv-items-found]
    <strong>Tickers:</strong>
    <!-- wpv-loop-start -->
    <wpv-loop>
        [wpv-post-body view_template="loop-item-in-ticker-terms"]
        [wpv-item index=pad-last]
        [wpv-post-body view_template="loop-item-in-ticker-terms-last"]
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    [/wpv-no-items-found]
[wpv-layout-end]

I have created an additional content temple "loop item in ticker terms last"

[wpv-taxonomy-link]
#2153571

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

That's close, but not quite correct.

You can see the correct format if you use the Loop Wizard and choose the List with Separators format, designed for the use case where you have a list separated by—say—commas, but you don't want a comma after the last item.

Given that your linked templates are so simple they are rather redundant and you could just put the shortcodes within the loop directly, e.g.

		<wpv-loop>
			[wpv-item index=other]
				[wpv-taxonomy-link] /
			[wpv-item index=last]
				[wpv-taxonomy-link]
		</wpv-loop>
#2155035

Excellent response! Thank you. You can close the ticket.

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