Try this:
function sw_custom_post_type_includes($query) {
$post_types = array('post','custom1','custom2','custom3');
if ( ! is_archive() && ! in_array( get_post_type(), $post_types ) )
return $query;
$query->set( 'post_type', $post_types );
return $query;
}
add_filter('pre_get_posts', 'sw_custom_post_type_includes');
Related Posts:
- Filter for “get_post_type_archive_link()”
- Filtering WP_Query
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- Is possible register two archive pages for single custom post type?
- Filter by custom field in custom post type on admin page
- Adding content to archive and taxonomy pages on custom post types?
- Filtering a custom post type by custom taxonomy in archive template
- get term archive url / link
- How to get the custom post type from an archive page?
- Adding a drag and drop re-ordering from a custom post type default list [closed]
- $query->set in pre_get_posts is unintentionally affecting the backend
- Pagination throws 404 error on custom taxonomy archive pages
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Archive page…limiting posts per page
- WP 3.1 – archive pages for custom content types possible now without a plugin?
- WP Admin default view mode for Custom Post Type
- Custom Post Type Archive URL takes over page URL
- Custom comment status possible?
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- How to Add Pages Under Custom Post Type URL Structure?
- Exclude custom function content from certain pages
- Filter get_categories() for taxonomy term in WordPress
- Debug output during filter execution doesn’t work
- Unable to filter on field on edit.php page
- Call different archive page based on post type
- Help with issues on “Adding a Taxonomy Filter to Admin List for a Custom Post Type?”
- Adding posts of custom type into the main feed
- Used with meta_query in query_posts works slowly
- How to create archive page for taxonomy terms within custom post type
- Category and post tag archives do not include posts from custom post type
- Custom Taxonomy breaking pages permalinks
- How do I set the link in the Custom Post Type admin menu?
- How to list custom post types?
- Display CPT description on archive.php pages for all CPT
- Pre_get_posts filter overwrites all search functionality
- WooCommerce product search titles only
- Custom query to filter posts that have current post as a taxonomy [closed]
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- Append date to custom post type url slug
- Custom Post Type Archive Page Filtering
- How to modify archive query with pre_get_posts to append CPTs?
- Genesis filterable portfolio isotope [closed]
- URL of a custom post type’s post format archive?
- Create template for taxonomy results limited by Custom Post Type
- filter custom post type by meta key in dashboard
- Categories of custom taxonomy don’t show any posts
- How to add a post slug to a url?
- Change CPT archive title
- WordPress sort search results by custom order
- The loop seems stuck to a single (now deleted) post
- Use “archive” as slug for custom post type
- Is it better to use filter for the_content in archive pages?
- How can I get this request to use the Custom Post Type page template instead?
- Create new custom post and post category of same name
- Archive not sorting correctly
- multiple custom post type on category page
- How can I use archive-{post_type}.php theme template?
- Taxonomy archive 404ing (not term archive)
- Custom taxonomy or custom page templates?
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- Custom Post Type setup
- Modifying WP_Title For Custom Post Type
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- pre_get_posts works in post type archive but not in single post
- Menu’s breaking, now showing all page links on site
- custom filtering admin columns
- users post count
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- Display category filters for custom post type when category is shared by multiple post types
- Create Post Types from a XML url (Real Estate website)
- Post Click Redirect to Custom URL instead of Single Post Page
- Custom WordPress theme not displaying posts from category
- Custom Post Type archive page listing a 404 or single post
- Order archive custom posts by taxonomy term [duplicate]
- Custom post type pagination problem – page 1 and 2 show same content
- The page or ad listing you are trying to reach no longer exists or has expired
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Keep br tags from stripping
- I broke it! Custom post type archive gets redirected to home
- Dropdown switching subcategories portfolio
- Filter Content on all Post Types
- Custom Post type archives / categories give 404
- Sorting on Taxonomy in archive page
- Filter custom post type by tags
- Custom Search Template for Custom Post Types
- Archive.php is not displaying tags
- Custom Post Types Archives and daily/monthly joke
- paging is not working properly on news archives page [duplicate]
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- is_singular won’t call my functions?
- Query Custom Post Type and sort by year
- Custom post types not using archive structure
- How to turn custom-post archive into an overview page, listing the metadata of the posts?
- Rewrite a filter as shortcode (or something like that) to use anywhere in CPT
- add_filter > posts_where works partially
- Filter page ID outside the loop and order
- Paginate yearly archives for a custom post type
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- coloring row’s background based on custom field value