WordPress.org

Ready to get started?Download WordPress

Forums

Sidemenu (3 posts)

  1. Eric Mann
    Member
    Posted 6 years ago #

    I want to add an administrative menu to the right-hand sidemenu of the dashboard (over where you find Settings, Plugins, and Users). I've managed to find the right hooks to manually add a link, and I can get the link to reference my plugin settings page.

    My problem is adding submenus to this new menu, and getting WP to recognize it as the current page. I'm using the following code to create the link:

    function rl_add_pages() {
    	echo '<li><a href="admin.php?page=rlplugin/rlplugin.php">RLPlugin</a></li>';
    }
    add_action('sidemenu', 'rl_add_pages');

    It renders the basic setting page just fine, but I only get the submenus if I also add it as a top-level admin menu through the standard admin_menu hook.

    Any suggestions?

  2. MichaelH
    Member
    Posted 6 years ago #

    Maybe this Codex article will help you -- Adding_Administration_Menus.

  3. Eric Mann
    Member
    Posted 6 years ago #

    MichaelH-
    Thanks for the advice, but that's not quite what I'm looking for. The hooks in that section of the codex will help me create top-level menus and submenus. It won't help me create the kind of top level menu I want.

    On the WP dashboard, there are two sets of top menus: On the left-hand side we have Write, Manage, Design, and Comments. On the right-hand side we have Settings, Plugins, and Users. The right-hand side menus are smaller and less intrusive. I want to add a top-level menu on that side, but the hooks in the Codex will only let me add submenus to the existing options.

    I did try the following, just to see if it would work:

    add_action('sidemenu', 'rl_add_pages');
    function rl_add_pages() {
        add_menu_page('RLPlugin Options', 'RLPlugin', 8, __FILE__, 'rl_options_page');
    }

    Unfortunately, it didn't add any pages at all. So far, I've only been able to add a top-level menu to the left hand side. The only way I can add anything to the right hand side is with the code I specified last time:

    function rl_add_pages() {
    	echo '<li><a href="admin.php?page=rlplugin/rlplugin.php">RLPlugin</a></li>';
    }
    add_action('sidemenu', 'rl_add_pages');

    Like I said, though, this doesn't really add a menu, just a link to the plugin file.

Topic Closed

This topic has been closed to new replies.

About this Topic