Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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 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 at 22:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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