Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The class selectors have changed slightly, it’s currently '.postbox .hndle, .postbox .handlediv' (.hndle in place of h3) for 4.1

    If that doesn’t help, all I can suggest is checking your browser console for javascript errors.

    Thread Starter Tyler

    (@tyleraldridge85)

    Ok here is the code I am now using:

    /**
     * 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(
            'post',
            // '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 .hndle, .postbox .handlediv', 'click', function() {
                        $( this )
                            .unbind( 'click.postboxes' )
                            .parent().removeClass( 'closed' );
                    } );
                } );
            </script>
            <?php
        }
    }

    There is still no change. Anybody else have any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How disable post box collapse’ is closed to new replies.