1

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 Answer 1

2

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 );
}
Sign up to request clarification or add additional context in comments.

1 Comment

Shazzad, thanks for the quick reply, your solution works. I was trying to do a simple thing in a complicated way :) Since (in my case) it was a custom post type, I've just printed the $menu array to see what is the array index of the menu item I wanted to change, and I've added the URL. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.