0

I have pages setup and want a top level menu item to direct to editing a specific page. I'm reading through add_menu_page and it doesn't list how to get to specific pages or posts edit page. ie post.php?post=FOO&action=edit.

Is this possible?

1 Answer 1

2

You've almost answered your own question. Just pass the URL as the $menu_slug to add_menu_page:

add_menu_page(
    null, // not an actual page, so title is irrelevant
    'Menu Item Name',
    'edit_posts', // or whatever capability required for this object
    '/post.php?post=42&action=edit',
    null,
    '',
    6
);

The caveat is that when you visit this menu item, the actual menu item it belongs to will be highlighted in the menu (posts, pages, media). You could fix this with a bit of JS, or just live with it.

2
  • Ahhh that was easy. But yeah I'd like not have it highlight away. Any links or snippets to take a look?
    – Tom
    Jan 9, 2014 at 22:46
  • on second thought, I don't know that it's fixable, as it's really physically the same page, you're just navigating to it by different means.
    – Milo
    Jan 9, 2014 at 22:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.