php - Wordpress search multiple tag combinations -
im trying search posts using tag-combinations can make in search form. cant combinations work.
the (checkbox) options;
colors: red, blue, black
shapes: round, square, diamond
i want display posts have these tag-combinations:
red , round
or
red , square
i tried doesn't seem work:
$query = new wp_query( 'tag=red+round,red+square' );
wordpress sees 'tag=red,round,red,square'.
anyone tip on how can work or maybe alternative route?
looks shorthand version of wp_query
not work in case, try below parameters wp_query
, detailed information available here: wp_query on wp codex
$args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'or', array( 'taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => array( 'red', 'round' ), 'operator' => 'and', ), array( 'taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => array( 'red', 'square' ), 'operator' => 'and', ), ), ); $query = new wp_query( $args );
Comments
Post a Comment