Skip Navigation

[Resolved] Content Template for single page of different taxonomy

This thread is resolved. Here is a description of the problem and solution.

Problem:
Content Template for single page of different taxonomy

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/content-template-for-single-page-of-different-taxonomy-2/#post-921569

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

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

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)

This topic contains 2 replies, has 2 voices.

Last updated by alejandroG-2 6 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#921311

Tell us what you are trying to do?
I want to use two different templates based on the taxonomy selected.
CPT is Events (Tickera plugin)
Taxonomy slug could be: "campamento" o "evento"

I tried several options:
First one:
[wpv-conditional if="( '[wpv-post-taxonomy type="event_category" format="slug"]' eq 'campamento' )" debug="true"]
<p>Campamentot!</p> [/wpv-conditional]

[wpv-conditional if="( '[wpv-post-taxonomy type="event_category" format="slug" ]' eq 'evento' )" debug="true" ]
<p>Evento! </p>[/wpv-conditional]

Second one:
[wpv-if evaluate="has_term('campamento', 'event_category', null) = '1'" debug="true"]
<p>CAMPAMENTO</p>
[/wpv-if]

[wpv-if evaluate="has_term('evento', 'event_category', null) = '1'" debug="true"]
<p>EVENTO</p>
[/wpv-if]

Third one:
[wpv-if evaluate="has_term('campamento', 'taxonomy-slug', null) = '1'" debug="true"]
<p>CAMPAMENTO</p>
[/wpv-if]

[wpv-if evaluate="has_term('evento', 'taxonomy-slug', null) = '1'" debug="true"]
<p>EVENTO</p>
[/wpv-if]

Debug info:

####################
wpv-if attributes
####################
Array
(
[evaluate] => has_term('campamento', 'taxonomy-slug', null) = '1'
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: has_term('campamento', 'taxonomy-slug', null) = '1'
--------------------
After expanding custom functions and date expressions: has_term('campamento', 'taxonomy-slug', null) = '1'
After matching 3 numeric strings into real numbers: has_term('campamento', 'taxonomy-slug', null) = 1
Matched '1' to 1
--------------------
End evaluated expression: has_term('campamento', 'taxonomy-slug', null) = 1
--------------------
La expresión condicional contiene caracteres no permitidos
####################
wpv-if attributes
####################
Array
(
[evaluate] => has_term('evento', 'taxonomy-slug', null) = '1'
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: has_term('evento', 'taxonomy-slug', null) = '1'
--------------------
After expanding custom functions and date expressions: has_term('evento', 'taxonomy-slug', null) = '1'
After matching 3 numeric strings into real numbers: has_term('evento', 'taxonomy-slug', null) = 1
Matched '1' to 1
--------------------
End evaluated expression: has_term('evento', 'taxonomy-slug', null) = 1
--------------------
La expresión condicional contiene caracteres no permitidos

Is there any documentation that you are following?:
https://toolset.com/forums/topic/content-template-for-single-page-of-different-taxonomy/
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153493

Is there a similar example that we can see?

What is the link to your site?
hidden link
hidden link

#921569

Minesh
Supporter

Languages: English (English )

Timezone: 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('campamento', 'event_category', null) eq '1' )"]
[wpv-post-body view_template="template-1"]
[/wpv-conditional]
 
[wpv-conditional if="( has_term('evento', 'event_category', null) eq '1' )"]
[wpv-post-body view_template="template-2"]
[/wpv-conditional]

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

#922812

Thanks a lot!