Skip Navigation

[Résolu] Can I confirm that THIS is the correct way to code the Views Loop

This support ticket is created Il y a 3 années et 3 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par PaulS4783 Il y a 3 années et 3 mois.

Auteur
Publications
#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

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00: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.