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 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.

snapshot2

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

1 Answer 1

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 )
        return;

    ?>
        <script type="text/javascript">
            jQuery(document).ready( function($) {
                $('#toplevel_page_post-post-69-action-edit').removeClass('wp-not-current-submenu').addClass('current');
                $('#toplevel_page_post-post-69-action-edit').find('a:last').addClass('current');
            });     
        </script>
    <?php
}
share|improve this answer
1  
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

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.