Im trying to create a function that place my page link http://mypage.com/mypage in the Admin Sidebar, not in the top Admin Bar like the code bellow does know.

function toolbar_link_to_my_page( $wp_admin_bar ) {
    $args = array(
        'id'    => 'my-page',
        'title' => 'My Page',
        'href'  => 'http://mypage.com/mypage',
        'meta'  => array( 'class' => 'my-personal-page' )
    $wp_admin_bar->add_node( $args );
add_action( 'admin_bar_menu', 'toolbar_link_to_my_page', 999 );

Can anybody give me a hint on how to solve that...


I have added custom menu link by following. Hope it will be helpful.

add_action( 'admin_menu' , 'custom_admin_menu_new_items' );
function custom_admin_menu_new_items() {
    global $menu;
    add_menu_page( 'My Page', 'My Page', 'manage_options', 'my-page', '','', 6 );
    foreach($menu as $mIndex => $mData) {
        if($mData[2] == 'my-page') {
            $menu[$mIndex][2] = 'http://mypage.com/mypage';

Action hook admin_menu is used. New menu is added by add_menu_page. And after that URL of the menu is overridden by checking the slug in the foreach loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.