You’ll want get_queried_object()
. This is a very generic function – and simply returns the queried object- so a single post, this would be a post object.
For instance, the return object may be of the form:
Object (
[term_id] => 299
[name] => test
[slug] => test
[term_group] => 0
[term_taxonomy_id] => 317
[taxonomy] => event-category
If on term-page -> get the current term? =>
[parent] => 0
[count] => 2
)
So for instance:
$q_object = get_queried_object();
if( isset($q_object->taxonomy) ){
$taxonomy = $q_object->taxonomy;
}else{
//Not a taxonomy page
}
To use this in a function:
function wpse51753_breadcrumbs(){
if( !is_tax() && !is_tag() && !is_category() )
return;
//If we got this far we are on a taxonomy-term page
// (or a tag-term or category-term page)
$taxonomy = get_query_var( 'taxonomy' );
$queried_object = get_queried_object();
$term_id = (int) $queried_object->term_id;
//Echo breadcrumbs
}
Then just wpse51753_breadcrumbs();
in your template wherever you want to display the breadcrumbs.