search multiple taxonomies (witch checkboxes)
-
Hi, I would like to have a search form where the user is able to check several taxonomies to search in (using the OR operator).
so my checkboxes elements have
name="yclad_category[]"
for example, which is an array.So I guess I have to implode this array before the query args are parsed.
I made this :
//explode checkboxes array when doing a search $_POST = yclads_implode_checkboxes_taxonomies($_POST); function yclads_implode_checkboxes_taxonomies($request_var) { $args = array('yclad_action','yclad_category'); foreach($request_var as $arg_key=>$arg_value) { unset($value); if (!in_array($arg_key,$args)) continue; $value= $request_var[$arg_key]; if (!$value) continue; if (!is_array($value)) continue; $new_args[$arg_key]=implode(',',$value); //'OR' operator } $new_args = array_filter((array)$new_args); $output = wp_parse_args( $new_args, $request_var ); //DEBUG $yclads_debug['checkboxes_args_before']=$request_var; $yclads_debug['checkboxes_args_after']=$output; return $output; }
when I print my $request->query_vars (using the hook parse_request), I got this
Array ( [post_type] => yclad [yclad_category] => cars,casting [taxonomy] => yclad_category [term] => cars,casting )
So by there it seems to be OK.
But then the query do not work. No posts are returned…Any idea of why ?
THanks !
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘search multiple taxonomies (witch checkboxes)’ is closed to new replies.