Using a custom post type post as the home page
written by: Jeff McNearUsing a custom post type post as the home page
Gutenberg is a terrific innovation and we should all embrace it, but there is still room for custom configured pages that consists of custom fields (I use ACF myself) and custom meta-boxes. Before gutenberg the ACF controls allowed for the hiding of the editor on a default post type… but Gutenberg cannot be so easily silenced.
You can still create a custom post type that doesn’t include the editor (gutenberg or not) by not including the editor in the capabilities line:
'supports' => array( 'title', 'trackbacks', 'revisions', 'page-attributes' ),
However the WordPress settings only allow for the assignment of a ‘page’ as an alternate main landing page for the site.
Thanks to this post: https://wordpress.stackexchange.com/questions/215199/how-to-set-a-custom-post-type-post-as-static-front-page for providing the appropriate addition to a functions file …
// ads landing page type to dropdown
function add_pages_to_dropdown( $pages, $r ){
if ( ! isset( $r[ 'name' ] ) )
return $pages;
if ( 'page_on_front' == $r[ 'name' ] ) {
$args = array(
'post_type' => 'landing_type'
);
$landing = get_posts( $args );
$pages = array_merge( $pages, $landing );
}
return $pages;
}
add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );
This code block will add any post of the “landing_type” to the “pages” already shown under the dropdown for “static page” selection found at:
=> settings
=> reading
BUT… the URL won’t resolve properly to the base URL so this may not be the solution I thought it was…