I’m using Roots Bedrock + Sage 9 Beta 3. I’ve created a custom post of type lp
that I want to set as my homepage. Here is the code I’m using:
function cptui_register_my_cpts_lp() {
/**
* Post Type: Landing Pages.
*/
$labels = array(
"name" => __( 'Landing Pages', 'sage' ),
"singular_name" => __( 'Landing Page', 'sage' ),
);
$args = array(
"label" => __( 'Landing Pages', 'sage' ),
"labels" => $labels,
"description" => "Pages without menus and/or totally custom layouts.",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => false,
"show_in_menu" => true,
"exclude_from_search" => true,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => [ "slug" => "lp", "with_front" => true ],
"query_var" => true,
"menu_icon" => "dashicons-welcome-widgets-menus",
"supports" => [ "title", "thumbnail", "excerpt" ],
);
register_post_type( "lp", $args );
}
add_action( 'init', 'cptui_register_my_cpts_lp' );
I’ve installed mpress-custom-front-page but it doesn’t seem to see my landing page.
So, with some digging, I noticed that it uses get_posts()
to get posts with post_type="any"
.
The query it sends is so:
$queried_post = get_posts([
'posts_per_page' => - 1,
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'any',
'post_status' => 'publish',
]);