Skip Navigation

[Resolved] Conditional display if is taxonomy type archive

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

Problem:

I'm trying to hide HTML on all 'Group' taxonomy archive pages, I'm not sure what conditional statement to use.

Solution:

It needs custom codes, I suggest you try these:

https://toolset.com/forums/topic/conditional-display-if-is-taxonomy-type-archive/#post-1242010

Relevant Documentation:

This support ticket is created 5 years, 1 month 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
- 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)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by morktron 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1241951

I'm trying to hide HTML on all 'Group' taxonomy archive pages, I'm not sure what conditional statement to use.

I don't see any option to say "If is taxonomy archive Group" - maybe I could use the URL but would I need Regex?

This is what I've tried:

[wpv-conditional if="( '[wpv-taxonomy-url]' eq 'group' )" evaluate="false"]<br>
  [wpv-post-date][/wpv-conditional]
#1242010

Hello,

Yes, you are right, it needs custom codes, I suggest you try these:
1) Create a custom shortcode to check current page is archive page of taxonomy "group", for example add below codes into your theme file functions.php:

add_shortcode("is_tax_sc", function($atts){
	$atts = shortcode_atts( array(
		'tax' => '',
	), $atts);
	$res = 0;
	if(is_tax($atts['tax'])){
		$res = 1;
	}
	return $res;
});

This will create a custom shortcode [is_tax_sc] to check if current page is archive page of specific taxonomy

2) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Third-party shortcode arguments", add the shortcode name: is_tax_sc

3) Use above shortcode like this:

[wpv-conditional if=" ( '[is_tax_sc tax="group"]' eq '1' ) "  evaluate="false"]
[wpv-post-date]
[/wpv-conditional]
#1242017

That works perfectly, thanks so much! :). I like how you've coded it to accept the taxonomy directly within the shortcode so it can be used elsewhere too without more changes to functions.php.

It would be great to have functionality like this built in. However, your solution is perfect, thanks again 🙂

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.