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'm looking to add an onmouseover tooltip link above the categories postbox/widget in the post editor screen of the Wordpress backend to help further clarify to the users on my site which is the most suitable category to post in.

Does anyone have a simple and elegant solution that avoids hacking the core files?

First I want to add the text:

Add text.

Then I want to add a Tool Tip like this when some one hovers the mouse over that text:

Tooltip

share|improve this question
add comment

1 Answer

Place this code in your functions.php theme (or child theme) file. It uses jQuery to add a new box above the Category div (<div id="categorydiv" class="postbox " >).

add_action( 'admin_footer-post.php',     'wpse_99252_add_categories_title_attribute' );
add_action( 'admin_footer-post-new.php', 'wpse_99252_add_categories_title_attribute' );

/**
 * Add a title attribute to categories box in the Post Editor.
 */
function wpse_99252_add_categories_title_attribute() { ?>
    <script type="text/javascript">

        // Setup tool tip box.
        jQuery( "#categorydiv" ).before( '<center id="categorydiv-tooltip">Which catgeory should I post in?</center>' );

        // Style it. Hide it.
        jQuery( "#categorydiv-tooltip" ).css( {
             'margin-bottom': '4px',
             visibility: 'hidden'
             // Add more styles here.
        } );

        // Display or hide tool tip box on mouse events.
        jQuery( "#categorydiv" ).mouseenter( function() {
            jQuery( "#categorydiv-tooltip" ).css( 'visibility', 'visible' );

        } ).mouseleave( function() {
            jQuery( "#categorydiv-tooltip" ).css( 'visibility', 'hidden' );
        } );

    </script>
    <?php
}
share|improve this answer
    
Hi Charles, thanks for the code. It's not however quite what I'm after... I was looking to add a piece of text above the categories box titled "Which category should I post in?" which upon mouseover shows a tooltip explaining which categories users should post in... any ideas? –  Paul Thomson May 14 '13 at 4:04
    
@paul-thomson See Edit. –  Charles Clarkson May 14 '13 at 4:45
    
Hey Charles, thanks for taking the time to make the additions, but still not what I'm trying to achieve... I'm looking to have a fixed piece of text labelled 'Which category should I post in?' above the categories box, and then when the user moves his mouse over this fixed piece of text, a tooltip appears with a further explanation of where to post. Please see link for futher clarification... thanks again, I feel we're almost there!! –  Paul Thomson May 14 '13 at 6:14
    
I edited your question. Is that what your really want? –  Charles Clarkson May 14 '13 at 12:54
    
Hi Charles, thanks for editing the question. I need a solution that would help clarify to the authors what categories they should post in as currently they are posting in the wrong categories all the time. Maybe a link to a popup might be more efficient? Any advise is warmly received. Thanks, Paul –  Paul Thomson May 15 '13 at 6:31
add comment

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.