WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry I'm new to taxonomies & trying to learn quickly.

I've set up sectors and assigned a post to it. If I go to the post, I can see the URL has www.mydomain.com/sectors/auto/

How can I get auto from the URL? Thanks

share|improve this question
Hi... try printing the query_vars using the filter 'query_vars', and look for the key with the value. – Rutwick Gangurde Aug 19 '11 at 15:42

I think you are looking for get_query_var

$term_slug = get_query_var( 'term' );
$taxonomyName = get_query_var( 'taxonomy' );
$current_term = get_term_by( 'slug', $term_slug, $taxonomyName );
share|improve this answer

Try this:

$sector = get_queried_object()->name;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.