Thanks to @toscho for the useful answer, but it felt a bit hackish to me, so I poked around a bit and figured out I could add a filter instead:
function wpa18013_add_pages_to_dropdown( $pages, $r ){
if('page_on_front' == $r['name']){
$args = array(
'post_type' => 'stack'
);
$stacks = get_posts($args);
$pages = array_merge($pages, $stacks);
}
return $pages;
}
add_filter( 'get_pages', 'wpa18013_add_pages_to_dropdown', 10, 2 );
Update
After adding the above code I was, indeed, able to use a custom post type as the home page, but WordPress would redirect the permalinks because it wasn’t a “page” post type. So http://localhost/test
would redirect to http://localhost/test/stacks/home-stack
, which wasn’t what I wanted.
Adding this action, though, fixed that and queries my custom post type along with pages for the home page:
function enable_front_page_stacks( $query ){
if('' == $query->query_vars['post_type'] && 0 != $query->query_vars['page_id'])
$query->query_vars['post_type'] = array( 'page', 'stack' );
}
add_action( 'pre_get_posts', 'enable_front_page_stacks' );