WordPress.org

Ready to get started?Download WordPress

Forums

Add Admin Menu Link to Specific Page (2 posts)

  1. cpoteet
    Member
    Posted 5 years ago #

    Can I use add_submenu_page to go to a specific page? i.e. add a link under "Appearance" that goes to (for instance) google.com?

  2. artjunky
    Member
    Posted 5 years ago #

    No, but you can use the adminmenu hook to add to the menu system. That's with no underscore. If you want it to match style of admin menu do something like this.

    //this inputs our custom menu
    add_filter('adminmenu', 'newMenu');
    function newMenu() { ?>
            <li class='wp-has-submenu menu-top menu-top-first menu-top-last'>
            <div class='wp-menu-image'><br /></div>
            <div class='wp-menu-toggle'><br /></div>
            <a href='admin.php?page=sub-page' class='wp-has-submenu menu-top menu-top-first menu-top-last' tabindex='1'>MenuName</a>
    
            <div class='wp-submenu'>
            <div class='wp-submenu-head'>Menu Name</div>
            <ul>
                    <li class='wp-first-item'><a href='admin.php?page=sub-page' class='wp-first-item' tabindex='1'>Link</a></li>
                    <li><a href='admin.php?page=sub-page&amp;display=6&amp;query=2'>Link</a></li>
                    <a href='admin.php?page=sub-page&amp;display=6&amp;query=3'>Link</a></li>
            </ul>
            </div>
    
            </li>
    
    <?php }

    You can put in any links you want that way. If you follow that style the menu will be collapsible like the other admin menus.

Topic Closed

This topic has been closed to new replies.

About this Topic