After you have set a static page as your home page you can add this to your functions.php
and you are good to go. This will call the archive-POSTTYPE.php
template correctly as well.
add_action("pre_get_posts", "custom_front_page");
function custom_front_page($wp_query){
//Ensure this filter isn't applied to the admin area
if(is_admin()) {
return;
}
if($wp_query->get('page_id') == get_option('page_on_front')):
$wp_query->set('post_type', 'CUSTOM POST TYPE NAME HERE');
$wp_query->set('page_id', ''); //Empty
//Set properties that describe the page to reflect that
//we aren't really displaying a static page
$wp_query->is_page = 0;
$wp_query->is_singular = 0;
$wp_query->is_post_type_archive = 1;
$wp_query->is_archive = 1;
endif;
}
Related Posts:
- How to set a custom post type to have viewable future posts
- How to get_queried_object on multiple objects?
- How to use WP_Query in a CPT achive page?
- is_main_query() not working for WP REST API
- WP_Query | ‘post_type’ doesn’t work
- Display featured image from one CPT within another CPT query
- CPT archive admin menu label
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Loop increase number
- Get current user id
- Using Wp_Query, Json to add Highcharts series data
- Query Posts that have Custom Taxonomy
- Foreach loop returning more than one item when querying taxonomy
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Custom Form / Search with Custom Post Type Data
- set object terms after some some time of published post – functions.php
- Different number posts per page based on custom post type term id
- How to add specific terms in a custom post type?
- Tell wordpress to show a single page instead of an archive page
- subtracting the current post form then whole loop, which is generating all CPT titles
- Only show categories that have posts within custom post type
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- why custom post archive gives always no more than 10 posts despite of paging settings?
- WP_Query function for custom post type
- Modify shortcode to work with custom taxonomies and slugs
- Pagination fault in custom post type archive page [duplicate]
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Page Template as Custom Post Type Archive
- Select All in Parent Category, Group by Child Category?
- get_query_var() not working in pre_get_posts
- WP_Query ignores post_type in category view
- Pre_get_posts Gives 404 on Custom Post Type
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- custom post type upcoming post and past post
- Query for posts from any post type but only add instock products
- Query not returning CPT posts
- Custom Taxonomy and tax_query Issue?
- Unable to display multiple post types in same query (WPML WP_Query)
- Add multiple custom post types in functions.php, but only one custom post type show in dashboard
- WP_Query with custom post_type and cat retrieving unwanted posts with the custom posts
- Query to get the author who having maximum number of post (custom post type)
- Pagination not working
- How to use custom post type APIs, but use a different db table
- Show Post Count of a Category
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- How would I create a shortcode to display a custom post within a page or regular post?
- WP Query—Relationship between two custom post types and their fields
- Unable to get paginate_links working with a custom query [duplicate]
- Filter categories of posts with checkboxes
- Setting proper query for multiple custom admin filters
- Randomize Posts. Skip the first post in ascending order
- Custom taxonomy rewrite give pagination 404
- WP_Query order by custom field, then randomly order some of results
- Display custom post type category, while in a CPT category, then the posts beneath
- How to display post list inside post
- How to have this permalink structure: post_type/postname/custom_inner_page
- Want to be able to sign up subscribers as authors
- Advanced search form with filters for custom taxonomies
- WP the_posts() on single-cars.php get category link
- tax_query not working in template
- Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()
- Custom post type archive with page as parent url
- categories should be available across all custom post types
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Custom WP_Query always respond with 200 status even when no entry
- Url to archive page for custom post type
- Page Template Dropdown For Custom Post Types
- Pagination 404 on Index with custom query
- WP_Query parameter conflict
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- adding custom post type “name” to single template
- Custom Post Type Archive Pagination
- List all Custom Post Type posts excluding certain Taxnomy term
- Custom post type pagination error
- Is possible register two archive pages for single custom post type?
- WP query_posts group by meta field related
- Apply category query clause to posts of custom type
- custom post type and a “sticky” position taxonomy
- Display post count for a specific month
- WP_query has incorrect wp_posts.post_name = ‘asc’ when I have custom post type called ‘order’
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- 2 modal windows with ACF content on Archive page
- Custom Post Type – Display all, wrap in groups of 3
- Staggering featured post using ‘sticky’
- Ajax load more inside custom post type taxonomy
- Meta_query by date for Events archive
- Create a custom wp_query from a specific custom post type with specific taxonomy
- How to mark posts as visited
- Query breaking with ‘posts_per_page’ => -1
- Custom post type archive page not showing on archive-posttype.php
- WP Query with multiple post types ordered by custom meta date then published date
- Query Pulling the same post twice
- Templates list in “Page Attributes” metabox is inaccurate
- Stop Custom post type from being searched via URL
- Querying meta values within an array
- Pagination not working for archive
- Filter Custom post type by another Custom post type
- Archive page – problem with pagination
- How to use wp_set_object_terms depending on page ID?