Skip Navigation

[Resuelto] Show different Views on two different product category archives

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I have two Product Categories and two different Views. I would like to include one View on the Product Category archive for term "pierres-precieuses" and the other View on the Product Category archive for term "diamant".

Solution: Use conditional HTML inside your WordPress Archive that tests the current archive slug:

[wpv-conditional if="('[wpv-taxonomy-archive info='slug']' eq 'pierres-precieuses')" ]
[wpv-view name="pierres"]
[/wpv-conditional]
[wpv-conditional if="('[wpv-taxonomy-archive info='slug']' eq 'diamant')"]
[wpv-view name="test"]
[/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive

This support ticket is created hace 6 años, 7 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Este tema contiene 20 respuestas, tiene 3 mensajes.

Última actualización por ThierryR232 hace 6 años, 7 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#648518

Hi, it's good.

#648780

Hello, I am still expecting a list of questions. What specific concerns will we discuss during the meeting? I need to know before the call so we can plan. Without a list of questions, I cannot justify a video call.

#648847

In fact just this :

I want just displaying a different content (with their custom fielfd) for the category product X and product Y.
I have or a view X or a view Y,

i didn't succeed to work.

#648848

Okay thank you, I will see you in 30 minutes.

#649142
Screen Shot 2018-04-11 at 11.09.17 AM.png

Okay I figured out the problem with the conditional HTML code - I was missing some quotation marks. Here is the updated conditional code:

[wpv-conditional if="('[wpv-taxonomy-archive info='slug']' eq 'pierres-precieuses')" ]
[wpv-view name="pierres"]
[/wpv-conditional]
[wpv-conditional if="('[wpv-taxonomy-archive info='slug']' eq 'diamant')"]
[wpv-view name="test"]
[/wpv-conditional]

Next, I added a Product Category filter to each View. See the attached screenshot. The Product Category filter is set by the current archive.

Now, you can see the two different Views appearing here:
enlace oculto
enlace oculto

Next steps to consider:
- What about other Product Category archives? If you have another product category, no View will appear. You must add another conditional for each archive.
- Are different Views really necessary? You can use condtionals in the Filter Editor and Loop Output instead, and then you only need one View:

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="form-group">
	[wpv-control-postmeta field="wpcf-purete" type="select"  default_label="Quelle pureté ?" url_param="wpv-wpcf-purete"]
</div>
[wpv-conditional if="('[wpv-taxonomy-archive info='slug']' eq 'diamant')"]
<div class="form-group">
	[wpv-control-postmeta field="wpcf-couleur" type="select"  default_label="Quelle couleur ?" url_param="wpv-wpcf-couleur"]
</div>
[/wpv-conditional]
<div class="form-group">
	[wpv-control-postmeta field="wpcf-forme" type="select" default_label="Quelle forme ?" url_param="wpv-wpcf-forme"]
</div>
...
</div>
#649705

Great, good job Christian, i understand and i create a new category, it's work 🙂