Skip Navigation

[Resolved] Setting a specific style for the current archive term in a View of terms

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

Problem: I have a View of taxonomy terms displayed on my taxonomy WordPress Archive pages. I would like to highlight the current archive term in the View.

Solution: Use conditional HTML to compare the current archive term slug and the slug of the current term in the loop.

[wpv-conditional if="('[wpv-taxonomy-slug]' eq '[wpv-taxonomy-archive info='slug']')"]
This term matches the current archive term!
[/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-slug

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
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)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Tcoffee 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#951346
functions.png
Screenshot_3.png
Screenshot_2.png

I am trying to: add a specific style to the active taxonomy item in the sidebar menu in taxonomy archive page

Link to a page where the issue can be seen: hidden link

I had tried this: https://toolset.com/forums/topic/setting-a-specific-style-for-the-active-taxonomy/

but not working. please help me to fix this.

#951585

Hi, you can accomplish this without a custom shortcode. In a View of taxonomy terms, you can get the current term slug like you already implemented:

[wpv-taxonomy-slug]

In a taxonomy term WordPress Archive, you can get the slug of the archive term like this:

[wpv-taxonomy-archive info="slug"]

So in the View of terms, you can compare these two values in a conditional:

[wpv-conditional if="('[wpv-taxonomy-slug]' eq '[wpv-taxonomy-archive info='slug']')"]
This term matches the current archive term!
[/wpv-conditional]

Here's the documentation for the wpv-taxonomy-archive shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive

#953521

thank you, Christian. that solved my issue.