• Resolved cscott5288

    (@cscott5288)


    I understand that I can add an admin link which links to a page generated by a specified function, but I just want to link to a URL (not a page generated by a function). Specifically, an Edit view of a particular page. So the admin menu link will essentially take you to Pages –> [Page Name] –> Edit. Is there a way to do this? I couldn’t find it here: https://codex.www.ads-software.com/Administration_Menus

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • $wp_admin_bar->add_node() should be able to do what you want: https://codex.www.ads-software.com/Function_Reference/add_node

    Specifically, you can take a look at this example from that page:

    add_action( 'admin_bar_menu', 'toolbar_link_to_mypage', 999 );
    
    function toolbar_link_to_mypage( $wp_admin_bar ) {
    	$args = array(
    		'id'    => 'my_page',
    		'title' => 'My Page',
    		'href'  => 'https://mysite.com/my-page/',
    		'meta'  => array( 'class' => 'my-toolbar-page' )
    	);
    	$wp_admin_bar->add_node( $args );
    }
    Thread Starter cscott5288

    (@cscott5288)

    Thanks for the help, OldRiver. This is sort of what I want. But instead of adding a link to the admin bar, I want to add it to the admin menu, the vertical menu on the left-hand side in the wordpress backend. Apologies for not explaining it correctly.

    Moderator bcworkz

    (@bcworkz)

    You were on the right track with Administration Menus, but you needed to dig a bit deeper. See Function_Reference/add_menu_page. In the parameters section you can see if you provide a $menu_slug argument that is a PHP file and omit the $function parameter, that PHP page is displayed when the menu option is selected. Many of the default admin panels work this way. Sub-menus have a similar setup.

    Thread Starter cscott5288

    (@cscott5288)

    bcworkz, thanks! I overlooked that part because I was looking for something like a URL parameter instead of a ‘slug’ parameter. But this will work just fine for me. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding a admin menu item that links to a URL’ is closed to new replies.