0

Im using:

// wp-admin hotels list in sidebar
function add_custom_submenu_under_add_new() {
    $args=array(
        'post_type' => 'hotel',
        'posts_per_page' => -1,
        'post_parent' => 0
    );
    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            global $post;
            add_submenu_page(
                'edit.php?post_type=hotel', // parent slug
                get_the_title($post->ID), // page title
                get_the_title($post->ID), // menu title
                'edit_posts', // capability (use the same as for editing posts)
                'post.php?post='.$post->ID.'&action=edit'
            );
        }
    } 
    wp_reset_postdata(); 
}
add_action('admin_menu', 'add_custom_submenu_under_add_new');

To add custom menu to wp-admin sidebar under custom post type (hotel). What I need to do is to add second level menu to every created item, so I can show there subpages of this CPT. Is there any way to achieve that?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.