Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Tag Search WordPress

Wordpress 3.5.2. Old construction like

?tag=tag1+tag2

doesn't work any more. i dunno why. I have a form with check boxes. And tags which sorts by category. So i wanna search by

tag1+tag2+tag3

in specific category. How to do that? I'm tired look for a solution :(

like image 640
Евгений Антипов Avatar asked Sep 02 '26 07:09

Евгений Антипов


1 Answers

Comma separate them:

/** posts with any of the following tags */   
$query = new WP_Query( 'tag=bread,baking' );

/** posts with all of the following tags */
$query = new WP_Query( 'tag=bread+baking+recipe' );

/** or alternatively */
$query = new WP_Query( array( 'tag_slug__in' => array( 'bread', 'baking' ) ) );

Documented here: http://codex.wordpress.org/Class_Reference/WP_Query

like image 141
wunderdojo Avatar answered Sep 04 '26 22:09

wunderdojo