Private Pages as Root Page for CPTs

Traditionally, the Breadcrumb NavXT settings page has only allowed published/publicly visible pages be the root page for custom post types. This follows what WordPress core does with the homepage and posts page. However, in some circumstances, having a private page be the root page for a custom post type makes sense.

Introduced in Breadcrumb NavXT 7.4, the bcn_admin_post_root_args filter allows for control over the arguments passed into the root page drop down. Below is an example of using the bcn_admin_post_root_args filter to allow private pages to show up in the root page drop down:

add_filter('bcn_admin_post_root_args', 'my_bcn_admin_post_root_args', 10, 2);
function my_bcn_admin_post_root_args($args, $post_type_name)
{
	$args['post_status'] = array('publish','private');
	return $args;
}

This can be extended to only allow private pages to be the root page for specific post types (by checking the $post_type_name parameter for the desired post type). Lastly, while the setting is for the root page, it does not have to be limited to the page post type.

-John Havlik

Leave a Reply

Your email address will not be published. Required fields are marked *