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

I will share my code and I hope someone reviews it since I'm not expert in event handling.

This goes inside your plugin or your theme functions.php:

 * Disable meta box toggling (collapse/expand) for specified post types
add_action( 'admin_footer', 'wpse_39723_disable_metabox_toggle' );
function wpse_39723_disable_metabox_toggle() {    

    $current_screen = get_current_screen();

    // Array of post types where we want to remove metabox toggling
    $post_types = array(
        // 'page',
        // 'my_custom_post_type',

    if( in_array( $current_screen->id, $post_types ) ) {
        <script type="text/javascript">
            jQuery( document ).ready( function($) {
                $( '.postbox' ).removeClass( 'closed' );
                $( '.postbox .hndle' ).css( 'cursor', 'default' );
                $( document ).delegate( '.postbox h3, .postbox .handlediv', 'click', function() {
                    $( this )
                        .unbind( 'click.postboxes' )
                        .parent().removeClass( 'closed' );
                } );
            } );
share|improve this answer

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.