Add a function hooked to pre_get_posts
which modifies post_type
argument of the main query to add your custom post type.
function wpd_home_post_types( $query ){
if( $query->is_home() && $query->is_main_query() ){
$query->set( 'post_type', array( 'post', 'natural_food' ) );
}
}
add_action( 'pre_get_posts', 'wpd_home_post_types' );
Related Posts:
- Where to put my code: plugin or functions.php?
- Custom post type – order field
- Change permalinks for posts but not for custom post types
- Assign single template to multiple custom post types?
- How to build a complex page structure
- How to put custom post types on front page
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to a custom post type single post?
- How can I fix those issues generated by the Themecheck plugin
- Why is get_post_format() for “Standard” returns empty
- Password-protect a custom rss feed
- Rename a current used post type
- Template tags to display custom post type posts in category template?
- Custom Search form not working in localhost
- Group search results by post type, but hide post types with no results
- single-type.php not working, delivering 404
- Multiple Content Block
- Message on Custom Posts Type admin page
- adding .current* tags to custom post types and taxonomies
- How do I create an archive page for standard posts?
- Is it possible to associate different kinds of custom post types one to the other?
- Limit users by custom taxonomy and user roles
- Remove parent from custom post type
- Page as a child of a Custom Post Type
- How to add extra input fields to CPT’s comment form?
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Displaying a custom post types custom taxonomy value?
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- What template files do I need to customise custom-category-term-links rather than fall back on archive.php?
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Help need making decision. Ads rotating site on wordpress
- Query & Order posts by custom fields
- custom taxonamy and post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Not Able to Get Custom Post Type Gallery Images URL
- Display a grid of taxonomy terms at root taxonomy page
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Building a Treatments Page, What Do I Use?
- How to specify a template for a path like http://example.com/something?
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Getting Un Wanted Gallery Shortcode In The Page on Loop
- Display custom post using ID
- Custom WP_Query doesn’t display all posts
- Two column layout with alphabetical ordering
- Custom post type permalink sends to 404.php
- Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)
- how to get this tax_query working?
- Show Taxonomies with admin area for custom post type?
- Pagination doesnt work in custom post type
- Custom post type’s posts are not showing anywere but in xml sitemap
- Assign a template to a custom post type when displayed by the main loop on the home page
- If Post type use sidebar (‘tree’)
- Having Issue on Getting Metabox Checkbox Value
- Custom meta box in custom post type not working
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- How can I tell if I’m on a custom post type archive page?
- Front end create custom post types
- Not Able to Add New Class To CPT Attachment Image
- How to Enable Ascending or Descending In WordPress Default Built-in Loop
- How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?
- How to get the custom post data using post id in WordPress?
- Loop all post on single.php
- How can I make reusable post types with complex custom field structures?
- Custom post type 404 category page
- Manually adding current_page_parent to wp_list_pages()
- programmatically generated custom post type is created more than once
- Add extra elements to the_post in a custom post_type
- Visualize info in just custom post_type in theme
- cpt not display inside nav menu
- How to use posts as tabs in a custom page?
- Issue on Getting URL of Uploaded Image to a Custom Post Type
- Custom Post Type has wrong label and is not found when called by a loop
- Problem with multi checkboxes value in metabox?
- Custom Post Type archive page listing a 404 or single post
- Too many revision when post status is changes [duplicate]
- Create dynamic logo carousel without using any plugin
- Having issue on Loading Meta Data From CSV to CPT
- call a function when insert and update a custom post type
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- creating a custom post template
- 2 custom posts types, in their own columns, one pagination for both
- How To Display Category list from Portfolio post type plugin?
- Custom post type with custom taxonomy permalinks
- Search form to find custom meta box generated data
- Query custom post type and showing its content
- Issue on Counting CPT’s Under Taxonomy Term
- Function that get ACF fields value before saving
- Why is my custom form saving with ‘autodraft’ as title and slug?
- Author profile comments system
- Create custom post order (with custom post type meta)
- Custom post type and custom taxonomy archive inaccessible
- Apply custom names for generic custom taxonomy name?
- Change position of Post Formats box?
- Category names on CPT archive pages [closed]
- Single page for Custom Post Type not found
- How to create custom page templates with default page layout framework?
- Need some hints for my own WP theme development
- Can you programme the selected page template to display block patterns automatically?
- Show custom post type on post category page doesn’t work / breaks navigation