I have two custom post types, one of which I need to be able to select as a parent of the other. Post type A has a url structure www.mydomain/posttypeA/posttypeAsingle
, and I need to allow post type B to select a parent from post type A so the url displays www.mydomain/posttypeA/posttypeAsingle/posttypeB
By creating Post Type B as such, it allows me to select a parent of ITS OWN post type, but does not allow me to select a parent from a different post type (Post Type A):
register_post_type('posttypeB',
array(
'labels' => array(
'name' => __('Post Type B', 'textdomain'),
'singular_name' => __('Post Type B', 'textdomain'),
'add_new' => __('Add New Post Type B'),
'add_new_item' => __( 'Add New Post Type B' ),
'edit_item' => __( 'Edit Post Type B' ),
'new_item' => __( 'New Post Type B' ),
'all_items' => __( 'All Post Type B' ),
'view_item' => __( 'View Post Type B ),
'search_items' => __( 'Search Post Type B' ),
'not_found' => __( 'Nothing found' ),
'not_found_in_trash' => __( 'Nothing found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Post Type B'
),
'public' => true,
'description' => 'Sessions are posted here',
'public' => true,
'menu_position' => 4,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'page-attributes' ),
'taxonomies' => array('category', 'post_tag'),
'menu_icon' => 'dashicons-welcome-learn-more'
)
);
How can I allow posts belonging to Post Type B, to select a parent from Post Type A in order to maintain the desired URL structure?