Skip Navigation

[Resolved] Setting a specific style for the active taxonomy

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#584593
Screenshot 2017-10-31 15.14.04.png
Screenshot 2017-10-31 15.13.03.png

I have a taxonomy list A to Z... I am trying to create a conditional so that the current taxonomy page I am on highlights the appropriate navigation item.

For Example taxonomy view displays links |A|B|C|D|E|F|G|... etc

When some one click "B", I want to change the style so that B is bolded and is a different color while all of the other links stay the same as they were.

I feel like I am over thinking this, This is what I am using for my loop. Screen shots are attached.

<div class="hide-at-414">By Last Name:  
<wpv-loop>
[wpv-conditional if="( '[wpv-taxonomy-title]' eq '[wpv-taxonomy-slug]' )"]
<span class="alpha-font-active">[wpv-taxonomy-link]</span>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-taxonomy-title]' ne '[wpv-taxonomy-slug]' )"]
<span class="alpha-font">[wpv-taxonomy-link]</span>
[/wpv-conditional]
</wpv-loop>
</div>

I hope that makes sense. Basically I just want to highlight the taxonomy choice for the page you are on.

#584766

Dear stephen,

It needs some custom codes, here is the detail steps:
1) Create a shortocode [is-tax] to check current page is the specific term's archive page, add below codes into your theme/functions.php:

function my_is_tax_func($atts, $content){
	
    $args = shortcode_atts( array(
        'term' => 0,
        'tax' => 'category',
    ), $atts );
	
	$res = 0;
	$obj = get_queried_object();
	if((isset($obj->term_id) && $obj->term_id == $args['term'])
		&& (isset($obj->taxonomy) && $obj->taxonomy == $args['tax'])
	){
		$res = 1;
	}
	return $res;
}
add_shortcode( 'is-tax', 'my_is_tax_func');

2) Dashboard-> Toolset-> Settings
option "Third-party shortcode arguments", add the srhortcode name: is-tax

3) Use [is-tax] in the wpv-conditional shortcode, like this:

              [wpv-conditional if="[is-tax term=[wpv-taxonomy-id] tax='category'] eq 1"]
				<span class="alpha-font-active">[wpv-taxonomy-link]</span>
              [/wpv-conditional]
              [wpv-conditional if="[is-tax term=[wpv-taxonomy-id] tax='category'] ne 1"]
				<span class="alpha-font">[wpv-taxonomy-link]</span>
              [/wpv-conditional]

Please replace "category" with your custom taxonomy slug

The forum ‘Types Community Support’ is closed to new topics and replies.