0
votes

I need to implement menu navigation shown in front same in backend in wordpress, need to show hierarchy of main page (as menu) and sub-pages as sub-menu in backend. I also searched for plugin also (https://wordpress.org/plugins/admin-collapse-subpages/ and https://wordpress.org/plugins/cms-tree-page-view/) but these plugins are also not fulfilling the required behaviour. Can anyone please help me on this.

1

1 Answers

0
votes
// create page in admin panel
add_action('admin_menu', function(){
    add_menu_page( 'Some admin', 'Admin page', 'manage_options', 'site-options', 'add_my_setting', '', 4 ); 
} );


function add_my_setting(){

    // get the menu
    wp_nav_menu( array(
    'theme_location'  => '',
    'menu'            => 'main_menu', 
    'container'       => 'div', 
    'container_class' => 'some-container-class', 
    'container_id'    => '',
    'menu_class'      => 'menu', 
    'menu_id'         => '',
    'echo'            => true,
    'fallback_cb'     => 'wp_page_menu',
    'before'          => '',
    'after'           => '',
    'link_before'     => '',
    'link_after'      => '',
    'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    'depth'           => 0,
    'walker'          => '',
) );
}

// and add you styles for menu with some-container-class
add_action('admin_enqueue_scripts', function(){
    wp_enqueue_style( 'myPluginStylesheet', plugins_url('stylesheet.css', __FILE__) );
});