WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have implemented a Custom menu item in my wordpress dashboard using the following command in the functions.php

function create_menu() {
    $settings_page = add_menu_page('Edit_Post_69', 'Edit_Post_69', 'add_users', '/post.php?post=69&action=edit', '', get_stylesheet_directory_uri() . '/editicon.png', 2);

This works great and has added the icon into the dashmenu, included the icon and when clicked, takes me to the Edit Post page on post #69.

enter image description here

The problem I am facing is that even though I have clicked my custom link, the page it is currently on is the Edit Post page, this causes the Highlighted arrow to be on the Post section rather than my custom section as in the image below.


What I need is for my custom item to be highlighted as well, I have tried looking at filters and dug out _wp_menu_output, the idea being to filter the html and change the id class of the item to give it its highlighting.

Can anyone point me in the right direction of resolving this issue?

share|improve this question
Welcome to WPSE & +1 for the nicely formed Question! – brasofilo Jul 15 '12 at 15:33
up vote 2 down vote accepted

The probability is high that no hook will exist for that...

But it can be solved with jQuery:

add_action( 'admin_head-post.php', 'wpse_58567_highlight_menu_item' );

function wpse_58567_highlight_menu_item()
    global $post;

    if( 69 != $post->ID )

        <script type="text/javascript">
            jQuery(document).ready( function($) {
share|improve this answer
That is perfect, I have been trying to come up with a solution for so long now! Thanks for taking the time to reply – fightstarr20 Jul 15 '12 at 15:55
I am now trying to move on with this function and convert it so that it uses the post name instead of the Id. I have created a new question at wordpress.stackexchange.com/questions/59050/… - Any chance you could look in? – fightstarr20 Jul 19 '12 at 16:21
Thanks Brasofilo, Very active member of the WP community! I see your name everywhere those days ;) Anyway, if I have to resort to javascript I will but... isn't there a "non-hacky" way to do this now (meaning 2 years later)? – Alexandre Bourlier Aug 14 '14 at 11:20

Your Answer


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.