Skip Navigation

[Resolved] How to display current taxonomy name from url?

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 9 years, 7 months 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)

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by Shreyas Khatri 9 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#235453

Hi.

I've created a new taxonomy called 'sections', and i have created my View so it displays posts based on those 'sections' based on the url, eg '/?wpvsection=training'

But i cannot work out how to display the current taxonomy from that url, so the h1 reads <h1>Training</h1> , or what ever 'section' taxonomy is passed in the url.

Thanks.

#235609

Hi jeremya,

I suggest create a custom shortcode for it, like this:
Your custom taxonomy slug is "section",
1) add codes in your theme/functions.php

add_shortcode('current-taxonomy-name', 'current_taxonomy_name_func');
function current_taxonomy_name_func($atts, $value){
	extract( shortcode_atts( array(
		'value' => 'wpvsection',
		'field' => 'slug',
		'taxonomy' => 'section',
	), $atts) );
	$res = '';
	if(isset($_GET[$value]) && get_term_by( $field, $_GET[$value], $taxonomy)){
		$obj = get_term_by( $field, $_GET[$value], $taxonomy);
		$res = $obj->name;
	}
	return $res;
}

2) use above shortcode in your content, like this:
[current-taxonomy-name]

#235628

wow. thanks for that 🙂

#414388

Exactly what I was looking for. Awesome as always!

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

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