I am starting to learn wordpress plugin development and trying to add a additional sub menus in my plugin, following the documentation on post_type, i am trying to add a settings sub menu located in bottom of my plugin’s menu here is my code.

add_action( 'init', 'br_post_type');
function br_post_type() {
    $labels = array(
        'name'               => _x( 'Book Reviews', 'post type general name', 'book-reviews' ),
        'singular_name'      => _x( 'Book Review', 'post type singular name', 'book-reviews' ),
        'menu_name'          => _x( 'Book Reviews', 'admin menu', 'book-reviews' ),
        'add_submenu_page'          => _x( 'Settings', 'admin menu', 'book-reviews' ),
        'name_admin_bar'     => _x( 'Book Review', 'add new on admin bar', 'book-reviews' ),
        'add_new'            => _x( 'Add New', 'book', 'book-reviews' ),
        'add_new_item'       => __( 'Add New Book', 'book-reviews' ),
        'new_item'           => __( 'New Book Review', 'book-reviews' ),
        'edit_item'          => __( 'Edit Book Review', 'book-reviews' ),
        'view_item'          => __( 'View Book Review', 'book-reviews' ),
        'all_items'          => __( 'All Books Review', 'book-reviews' ),
        'search_items'       => __( 'Search Books Review', 'book-reviews' ),
        'parent_item_colon'  => __( 'Parent Books Review:', 'book-reviews' ),
        'not_found'          => __( 'No review found.', 'book-reviews' ),
        'not_found_in_trash' => __( 'No books review found in Trash.', 'book-reviews' )
    );

    $args = array(
        'labels'             => $labels,
        'description'        => __( 'Book review for our site.', 'book-reviews' ),
        'public'             => true,
        'rewrite'            => array( 'slug' => 'book_review' ),
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
        'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ),
        'menu_icon'                  => 'dashicons-book'
    );

    register_post_type( 'book_review', $args );
}

And i am trying to add my sub menu like this.

'add_submenu_page'          => _x( 'Settings', 'admin menu', 'book-reviews' ),

But nothing is displaying , any suggestions will help, thanks in advance!

Read more here: WordPress adding a sub menu on my plugin


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: