Well, looks like you’ve almost got it. To include multiple custom post types in the WP_Query object, just change:
$query->set( 'post_type', array( 'recipes' ) );
to:
$query->set( 'post_type', array( 'recipes', 'another-custom-post-type' ) );
Basically adding more elements to the array.
So the final code becomes:
function blestrecipes_cpt_filter( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_home() ) {
$query->set( 'post_type', array( 'recipes', 'another-custom-post-type' ) );
}
}
add_action( 'pre_get_posts', 'blestrecipes_cpt_filter' );
Related Posts:
- Call to a member function add_rewrite_tag() on null
- How to add custom taxonomy slug in CPT permalink?
- WordPress: Displaying all the post tags from within a specific taxonomy’s term
- Relationship between custom post type and page/single templates
- Display a query with multiple post types and same relationship on a single page
- Display all categories (with link) of custom post type – WordPress
- How can I get values from a custom post type depending on where I click on my SVG map?
- Displaying custom meta box value in a custom post page
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- WordPress different custom tag being displayed in on tag list
- How to enable REST API on custom post type without Gutenberg?
- Can I associate a custom post type with another custom post type?
- Get category name of current post (CPT UI)
- How to sort custom sortable column by custom table value
- I want to show image from custom field image on my custom page template
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- How to make multiple custom taxonomies sit under custom post type slug?
- Limit a search box by CPT + taxonomies, in only one page
- WordPress taxonomy and terms question
- Load style and script for custom post type metabox
- Custom CPT – Programmatically create categories to assign CPT when a new one is created
- Why do I get a 404 error on my custom post type archive pagination?
- How do I exclude the current post from the upcoming post query
- Save_Post change Custom Post Type Post title to post id number
- Custom Filtering date with newsletter
- Ajax infinite scroll random order shows duplicate posts on custom post type
- Custom post type removing /page/2/ from URL when trying to access it
- Same Custom Post Type Slug and Custom Taxonomy Slug, with hierarchial unique permalink structure
- fetch from an external api call and display results in page
- WordPress CPT & Custom Taxonomy with the SAME Permalink Structure
- Remove slug and custom post type name from URL
- Hot to show custom post type taxonomies on archive page
- Integrate a Custom Post Type with Learndash Plugin
- child category under correct parent
- Remove slug of multiple custom post types with and without hierarchical
- Redirect WordPress page to the latest created post by the logged in author/user
- create custom post type and populate custom fields using php
- Want to add custom post type for facebook feed
- Custom Post Types in WordPress Dashboard List Rows But Data is Blank
- Options of select field in a custom divi module ignore sorting
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?
- How to get the post title inside a custom block in a loop? block.js
- Set custom post type to load custom block pattern by default
- Post returns 404 after changing the permalink using post_type_link
- Transaction when using WP functions rather than vanilla SQL?
- How to run multiple Async HTTP requests in WordPress?
- Can i change wordpress emoji src from http://s.w.org/ to my site?
- List events by month
- Use wc_enqueue_js only on specific pages – nested add_action
- WordPress theme & site not loading after moving files
- Adding a span when custom post type is updated
- Removing unnecessary wordpress files
- How to merge local and live databases?
- WP_Query use for a filter with multiple Taxonomies and Terms
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Can I run custom php on specific pages in wordpress?
- Display All Post Attachments and Assign Class to the Last Image?
- Newbie question: no index.php? in my plain wordpress permalink
- enqueue hover function
- WordPress 3 – how are passwords stored and how do I compare to them?
- Use is_product_category() properly
- list posts and wrap them alphabetically A-Z
- Style wp_page_menu() items
- Proper use of internationalization
- Link to the parent post in attachment page
- Convert all images to PNG on file upload
- White Screen of Death – wp-admin
- How to update WP about renamed files
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- How to sanitize my cookie name
- How to select WooCommerce products by post_meta and order them
- If search results empty then execute certain code
- How to display selected taxonomies by their parent
- WordPress 5 WP REST routes – No errors
- Custom page archive query by url var calling page twice on one of my custom queries?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Custom Field Order by Last Name and First Name
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Add prefix to link url
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Change list item content in menu navigation to add a child element with specific class
- wordpress count link clicks by ip address
- Selectbox in admin panel function linking to CSS
- Is it better to create a function or a variable for current_theme_supports?
- wordpress allow user to edit user profile with custom fields
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- php script to change slug in post automatically
- Which field should I edit to make the checkbox marked by default?
- Add filter when image is uploaded?
- How can I save unique user data on my site? [closed]
- Add New User, extra fields which are required?
- Repeating admin-ajax.php not found error in admin
- Remove a div from RSS feed
- Add more button if more 8 items
- WordPress custom post type split into pages
- Keyword checking in Gravity Forms
- how to refresh div on template part?
- Child page menu in sidebar
- Any way to add -1 suffix to the end of every new post?
- Are all hooks/functions tied to Kses meant for sanitization?