1
votes

I'm trying to add custom menu item to the Dashboard menu, which will contain only link, not the whole page with the content.

For example: if I go to Posts and click on one of the posts titles to edit it - I'm redirected to the url something like: mydomain/wp-admin/post.php?post=58&action=edit. I want to create Dashboard menu link that goes directly to that edit page.

I've tried to use add_menu_page but this function adds a new page with the content to the dashboard menu, while all I need is to add dashboard menu item with the URL link (mydomain/wp-admin/post.php?post=58&action=edit) to go directly to edit a post.

1

1 Answers

2
votes

Yes, for this you will need to use global $menu or $submenu variable and use it on admin_menu hook -

add_action( 'admin_menu', 'se20782231_admin_menu', 99);

function se20782231_admin_menu()
{
    global $menu, $submenu;

    // if submenu is under Posts menu
    $parent_menu = 'edit.php';
    $menu_name = '';
    $capability = '';
    $url = '';

    $submenu[$parent_menu][] = array( $menu_name, $capability, $url );
}