Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sw_custom_post_type_includes($query) {
- $post_types_list = array();
- $args = array(
- 'public' => true
- );
- $output = 'names'; // names or objects, note names is the default
- $operator = 'and'; // 'and' or 'or'
- $post_types=get_post_types($args,$output,$operator);
- foreach ($post_types as $post_type ) {
- $post_types_list[] = $post_type;
- }
- if (!is_archive() && !in_array(get_post_types(), $post_types))
- return;
- $query->set( 'post_type', $post_types );
- return $query;
- }
- add_filter('pre_get_posts', 'sw_custom_post_type_includes');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement