submenu item edit a specific post

I’d like to have a submenu item in the admin section link directly to the edit form for a specific post ID, a custom post type at that.

Basically looking at using the add_submenu_page function to add the menu item http://codex.wordpress.org/Function_Reference/add_submenu_page which is easy.

Read More

Any ideas how to write a callback function to display the edit form for a specific post ID (which, in this case, happens to be a custom post type)?

Related posts

Leave a Reply

1 comment

  1. You do not need a callback function at all.
    You could display (yet another) custom edit screen, but if the custom post type is set up correctly you should be able to reach it simply by pointing to http://yourdomain.com/wp-admin/post.php?post=9999&action=edit where 9999 is any post ID that corresponds to a post of said type.

    Hence you can use post.php?post=9999&action=edit as the menu slug (see the codex page of add_menu_page for reference on parameters) with add_submenu_page and you’re good to go:

    add_submenu_page(
        'parent_slug',
        'Edit My Special Post', // page title, change to liking
        'Edit SP', // menu title, change to liking
        'edit_posts', // required capability, change to liking
        'post.php?post=9999&action=edit' // menu slug, change post ID
    );
    

    The last parameter, the callback function, you don’t need at all.