Guest User

Untitled

a guest
Jun 27th, 2012
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sw_custom_post_type_includes($query) {
  2.     $post_types_list = array();
  3.     $args = array(
  4.         'public'   => true
  5.     );
  6.     $output = 'names'; // names or objects, note names is the default
  7.     $operator = 'and'; // 'and' or 'or'
  8.     $post_types=get_post_types($args,$output,$operator);
  9.     foreach ($post_types  as $post_type ) {
  10.         $post_types_list[] = $post_type;
  11.     }
  12.     if (!is_archive() && !in_array(get_post_types(), $post_types))
  13.         return;
  14.  
  15.     $query->set( 'post_type', $post_types );
  16.     return $query;
  17. }
  18. add_filter('pre_get_posts', 'sw_custom_post_type_includes');
RAW Paste Data