WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding a admin menu item that links to a URL (5 posts)

  1. cscott5288
    Member
    Posted 9 months ago #

    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: http://codex.wordpress.org/Administration_Menus

    Thanks!

  2. OldRiver
    Member
    Posted 9 months ago #

    $wp_admin_bar->add_node() should be able to do what you want: http://codex.wordpress.org/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'  => 'http://mysite.com/my-page/',
    		'meta'  => array( 'class' => 'my-toolbar-page' )
    	);
    	$wp_admin_bar->add_node( $args );
    }
  3. cscott5288
    Member
    Posted 9 months ago #

    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.

  4. bcworkz
    Member
    Posted 9 months ago #

    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.

  5. cscott5288
    Member
    Posted 9 months ago #

    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!

Reply

You must log in to post.

About this Topic

Tags