Skip Navigation

[Resuelto] I need create a layout or content type only for one Taxonomy

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

Problem:
How to display conditional output based on taxonomy term

Solution:
You can use [wpv-conditional] shortcode to display conditional output.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/i-need-create-a-layout-or-content-type-only-for-one-taxonomy/#post-677105

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Este tema contiene 2 respuestas, tiene 2 mensajes.

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

Asistido por: Minesh.

Autor
Mensajes
#675991

Tell us what you are trying to do?
Hello,
I'm developing a site for a insurance company , with differents 'content templates' for each custom post type (depending of the goup of insuraces) .
3 in total: Insurances for enterprises , particular insurances , RC insurances
All the 3 custom types have a taxonomy: Online recruitment , Office hiring

For the time being, although the three templates are the same, I have made them separate in case in the future the client wanted to add different fields for each category. (Now, they have a description, coverages, others, & a button for more information that leaves to a contact form)

So now, the client want to add an aditional button only for the custom types with a determanted taxonomy. In this case he wants add a second button for 'hire online'

I'm not sure how to ad a custom type for a taxonomy, because now there are costom post type with this same taxonomy in the 3 custom post types.

Is there any documentation that you are following? Toolset help

Is there a similar example that we can see? i think only in our site.

What is the link to your site?
enlace oculto
and an example of this type of custom post that we need add a second button is:
enlace oculto

If you see the mega menu , you will see the post with 'online hiring'. Its not a custom post, i need :
- Or add this button only for a taxonomy
- Or made a conditional custom templete that appears for this taxonomy (that its in 3 types....)

I not sure how made that. I hope i explained well, my english is a liittle bit poor.

slt.

#677105

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can use [wpv-conditional] shortcode to display conditional output:

For example:

[wpv-conditional if="( has_term('term-1', 'category', null) eq '1' )"]
[wpv-post-body view_template="template-1"]
[/wpv-conditional]

[wpv-conditional if="( has_term('term-2', 'category', null) eq '1' )"]
[wpv-post-body view_template="template-2"]
[/wpv-conditional]

Where:
- Replace 'category' is your taxonomy slug.

Also - you need to register the has_term function at:
=> Toolset -> Settings => Front-end Content tab => Functions inside conditional evaluations

More info:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

#695121

Hello Minesh.

I did not understand the solution, because I did not know exactly where I had to put the code. I saw in the attached documentation that a particular view was created and that the condition showed one or another template. But I do not know if it's because I used visual composer or for what reason, but it gave me errors in the loop. For that reason I tried to do it in another way, since this code and the documentation made me try to make a conditional on the same button and it worked for me. I hope I have applied it correctly.
What I have done is make a block of text in the visual composer where I add the button that I want to appear only in online hiring.

[wpv-conditional if="( has_term('contractacio-online', 'modalitat', null) eq '1' )" ]

[dt_default_button link="#" size="big" default_btn_bg_color="#00378b"]Contractar[/dt_default_button]

[/wpv-conditional]

I do not know if it is correct. But it works for me. Although I would like to understand your solution.