Advertisement
Beee

searchwp_include

Dec 4th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <?php
  2. function my_searchwp_include( $ids ) {
  3.     if ( isset( $_REQUEST['country'] ) ) {
  4.         // limit the results to all of the chosen countries
  5.         $args = array(
  6.             'post_type' => 'any',
  7.             'nopaging' => true,
  8.             'fields' => 'ids',
  9.             'tax_query' => array(
  10.                 array(
  11.                     'taxonomy' => 'country',
  12.                     'field'    => 'slug',
  13.                     'terms'    => $_REQUEST['country'],
  14.                 ),
  15.             ),
  16.         );
  17.         $country_ids = get_posts( $args );
  18.         $c_ids = array_merge( $ids, $country_ids );
  19.         $c_ids = array_unique( $c_ids );
  20.     }
  21.     if ( isset( $_REQUEST['soort'] ) ) {
  22.         // limit the results to all of the chosen countries
  23.         $args = array(
  24.             'post_type' => 'any',
  25.             'nopaging' => true,
  26.             'fields' => 'ids',
  27.             'tax_query' => array(
  28.                 array(
  29.                     'taxonomy' => 'soort',
  30.                     'field'    => 'slug',
  31.                     'terms'    => $_REQUEST['soort'],
  32.                 ),
  33.             ),
  34.         );
  35.         $soort_ids = get_posts( $args );
  36.         $s_ids = array_merge( $ids, $soort_ids );
  37.         $s_ids = array_unique( $s_ids );
  38.     }
  39.     if ( isset( $_REQUEST['thema'] ) ) {
  40.         // limit the results to all of the chosen countries
  41.         $args = array(
  42.             'post_type' => 'any',
  43.             'nopaging' => true,
  44.             'fields' => 'ids',
  45.             'tax_query' => array(
  46.                 array(
  47.                     'taxonomy' => 'thema',
  48.                     'field'    => 'slug',
  49.                     'terms'    => $_REQUEST['thema'],
  50.                 ),
  51.             ),
  52.         );
  53.         $thema_ids = get_posts( $args );
  54.         $t_ids = array_merge( $ids, $thema_ids );
  55.         $t_ids = array_unique( $t_ids );
  56.     }
  57.  
  58.     $ids = array_merge( $ids, $country_ids, $soort_ids, $thema_ids );
  59.     return $ids;
  60. }
  61. add_filter( 'searchwp_include', 'my_searchwp_include' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement