Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to find only posts with a tag forest gump. I've tried: new WP_Query('tag=forest+gump');, new WP_Query('tag=forest gump');. However they both return ALL the posts and not only the posts with forest gump tag. Single tags (without spaces) work fine, though. Alternatives (like plain SQL) will work as well.

The entry tag line is forest gump, forrest gump, questend.

share|improve this question

1 Answer 1

up vote 2 down vote accepted
new WP_Query(array('tag_slug__in' => array('forrest-gump', 'forest-gump', 'questend')));

new WP_Query('tag=forrest+gump,forest+gump,questend'); should work too...

share|improve this answer
    
The + doesn't work, but the dashes work just fine. Thank you. Nevertheless, I didn't find this anywhere in the WP docs. –  Guy Jun 29 '11 at 12:25
    
@Guy WP_Query > Tag Parameters –  Rarst Jun 29 '11 at 12:50
    
@Rast, yes, I saw that page. Mind pointing out the paragraph that provides this information? –  Guy Jun 29 '11 at 17:20
    
This displays every article of those tags when I query it.. –  Maartje Mar 18 at 16:09

Your Answer

 
discard

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.