I’m writing a plugin that displays a post/page list in the admin menu, as a submenu for each post type. Here’s the code I’ve got far: http://pastebin.com/DmUGfzxN
The lists are showing and linking fine. However, I have a problem when I go to another menu, for example, Media, and go to edit a post (or image in this case). The current class that WordPress uses for the admin menu points to the wrong place, and opens the menu for Pages, highlighting the last submenu item.
I believe this is a related problem here: Current class on admin menu using add_submenu_page()
He solved it by adding the submenu page to a page slug, instead of a link like admin.php?=page...
. Unfortunately, I want my submenus to be under Post, Page, etc., so I need to use edit.php
and edit.php?post_type=...
.
If anyone has any ideas how to get around this quirk/bug, I’d appreciate it. Thank you.
I rewrote the code:
Now it displays the submenu, and the current class doesn’t affect it. Where I output the submenu, I changed the
<ul>
and<li>
to<div>
. I added a check to see if the menu item equals the current post being edited, and a little CSS in the admin_head to highlight the item. Please refer to the code paste above.Next, I’ll be looking into displaying child pages.