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

I'm encountering an issue when I want to display some articles based on a "composed" tag like "amnesty-international". The query doesn't return any results. The fact is I have two article tagged with this slug. This is the code I use in the template archive.php:

$current_tag =  single_term_title("", false);
$args= array(
    'post_type' => 'adverts',
    'tag' => $current_tag

$adsQuery = new WP_Query($args);

So this url doesnt return anything : http://www.mydomain.net/tag/amnesty-international/

Should I use another function ?

share|improve this question
single_term_title doesn't return slugs. It returns titles. It will return "Howdy Ho" instead of "howdy-ho'. See: wordpress.stackexchange.com/questions/54544/… – s_ha_dum Jan 24 '13 at 15:34
possible duplicate of Exclude Specific Term from Search – kaiser Jan 24 '13 at 16:24
@s_ha_dum Thx for your explanation, the topic did the trick. – aguidis Jan 24 '13 at 21:38

Thanks to a similar topic I can do it with :

$tag       = get_queried_object();
$tag_slug  = $tag->slug;

Or with this snippet :

$current_tag =  single_term_title("", false);
tag_slug = str_replace(' ', '-', $current_tag);
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.