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 trying to unbind the click handler on post metaboxes so they no longer hide when the handle is clicked. I need to do this because I use the handle to contain <select> elements & when changing these the click event is fired.

The code that binds the click handler is here: https://github.com/WordPress/WordPress/blob/master/wp-admin/js/postbox.dev.js#L8

Unfortunately the only way to unbind it seems to be editing this file & inserting the unbind inside add_postbox_toggles

Hope anyone can help

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can just put the necessary javascript in a file and enqueue it on the necessary page:

add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 );
function add_admin_scripts( $hook ) {    
//You can globalise $post here and enqueue the script for only certain post-types.
    if ( $hook == 'post-new.php' || $hook == 'post.php') {
        wp_register_script( 'my_js_handle','/path/to/js/my-js-file.js',array('jquery'),1,true);

With the javascript file containing:

    jQuery(document).ready(function() {
       jQuery('.postbox h3, .postbox .handlediv').unbind('click.postboxes');

(In, fact you could probably just 'print' it in the admin-footer).

share|improve this answer
Wow thank you so much, that worked a treat! But now I'm confused. Im currently calling add_action() inside a class constructor, which caused the problem. If I move it outside of the class however it works. Any ideas? –  studioromeo Jan 22 '12 at 1:52
add comment

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.