Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 24th, 2012  |  syntax: PHP  |  size: 0.74 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Basic search filter
  2.  
  3. function fteh_basic_filter($query) {
  4.         if ($query->is_search) {
  5.                 $query->set('post_type', array('post', 'factsheet', 'toolkit', 'report', 'whitepaper', 'issuebrief', 'pr'));
  6.         }
  7.         return $query;
  8. }
  9.  
  10. add_filter('pre_get_posts','fteh_basic_filter');
  11.  
  12. function fteh_query_vars( $query_vars ){
  13.     $query_vars[] = 'fteh_type';
  14.     return $query_vars;
  15. }
  16.  
  17. add_filter( 'query_vars', 'fteh_query_vars' );
  18.  
  19.  
  20. function fteh_pre_get_posts( $query ){
  21.     if( isset( $query->query_vars['fteh_type'] ) )
  22.         $types = explode( ',', $query->query_vars['fteh_type'] );
  23.         $query->set( 'post_type', $types );
  24.  
  25.     return $query;
  26. }
  27.  
  28. if ( ! is_admin() ) {
  29.      add_action( 'pre_get_posts', 'fteh_pre_get_posts' );
  30. }