WordPress add custom link instead of custom page in Dashboard menu

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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 );
    }