Parent Page List
According to your screenshot, it is using the classic editor, you may use get_pages() and get_pages hook to achieve the purpose.
- The page attribute meta box is created by page_attributes_meta_box() which use wp_dropdown_pages(), wp_dropdown_pages() then use get_pages() to load pages for creating options.
If I understand correctly, you want to add the original post type Page
to your custom post type Parent list. The following method could add any other post types to different post types. The example shows is adding Page.
add_filter( 'get_pages', 'ws361150_add_page_to_parent_list', 10, 2 );
function ws361150_add_page_to_parent_list( $post_type_pages, $parsed_args ) {
// if this is not admin page, return, since get_page is used in also navigation list in frontend
// avoid unnecessary rendering
global $current_screen;
// check to see if it is in edit post type page
// you may specify the post type $specify_post_type, if add to all custom post types, just leave it blank, if add to certain post types, use preg_match instead of strpos
$specify_post_type="";
if( empty( $current_screen ) || ! empty( $current_screen ) && is_bool( strpos( $current_screen->parent_file, "edit.php?post_type={$specify_post_type}" ) ) ) {
return $post_type_pages;
}
// add Page's page list to current page list or any post types
$additional_post_type="page";
$found_page = false;
// *** because it is a filter, need to check if it is already merge, if not doing this, infinite loop will occur
foreach ($post_type_pages as $key => $page) {
if( $page->post_type === $additional_post_type ) {
// var_dump('found');
$found_page = true;
break; // no need to continue if found
}
}
if( $found_page ) {
return $post_type_pages;
} else {
// add page list to current post type pages
$args = array(
'post_type' => 'page',
'exclude_tree' => $_REQUEST['post'],
);
$page_list = get_pages( $args ); // call again get_pages, the above test will return the page list without looping to add if it is already done
$pages = array_merge( $page_list, $post_type_pages );
// var_dump('add once');
return $pages;
}
}