Advertisement
Guest User

Displaying custom taxonomies based on form request

a guest
Mar 16th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. // Set any existing query string to a local variable
  2. $query_string = $_REQUEST;
  3.  
  4. // Setup the arguments for the query. Notice it is an OR query.
  5. $search['post_type'] = 'places';
  6. $search['tax_query'] = array(
  7.     'relation' => 'or',
  8. );
  9.  
  10. // Since we are using checkboxes, we'll want to loop over the request
  11. foreach($query_string as $key => $value) {
  12.     array_push(
  13.         $search['tax_query'],
  14.         array(
  15.             'taxonomy' => 'place_category',
  16.             'field' => 'slug',
  17.             'terms' => $value
  18.         )
  19.     );
  20. }
  21.  
  22. // Loop over the query's results
  23. while ( $the_search_results->have_posts() ) : $the_search_results->the_post();
  24.  
  25. // All my display stuff goes in here.
  26.  
  27. endwhile;
  28.    
  29. // Reset Query
  30. wp_reset_query();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement