Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use quick_edit_custom_box filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
April 13, 2023
5 minutes read

So, you’re diving into the world of WordPress hooks, eh? Today, let’s chat about the quick_edit_custom_box filter. This hook is quite handy as it fires once for each column in Quick Edit mode. To use it, you’ll want to register it using add_filter in your theme’s functions.php or, like many of us prefer, in a custom WordPress Plugin. This way, your modifications are safe even when you update your theme. And hey, if you ever need to backtrack, remove_filter is there to save the day.

Example 1: Enqueuing Scripts

Here, we load a custom script in the footer when editing posts of a specific type.

    if ( ! function_exists('weplugins_my_admin_enqueue_scripts') ):
    function weplugins_my_admin_enqueue_scripts( $hook ) {
        if ( 'edit.php' === $hook &&
            isset( $_GET['post_type'] ) &&
            'book' === $_GET['post_type'] ) {
            wp_enqueue_script( 'weplugins_custom_script', plugins_url('scripts/admin_edit.js', __FILE__),
                false, null, true );
        }
    }
    add_action( 'admin_enqueue_scripts', 'weplugins_my_admin_enqueue_scripts' );
    endif;
    

Example 2: Modify Column Name

This example shows how you can use the hook to modify the column name according to your needs.

    function weplugins_modify_quick_edit_custom_box_defaults($column_name, $post_type, $taxonomy) { 
        // Update the $column_name variable according to your website requirements and return this variable.
        return $column_name; 
    }
    // add the filter
    add_filter( "quick_edit_custom_box", "weplugins_modify_quick_edit_custom_box_defaults", 10, 3 );
    

Example 3: Removing a Hook

Need to undo your hook customization? Here’s how to remove a hook callback.

    remove_filter( "quick_edit_custom_box", "weplugins_modify_quick_edit_custom_box_defaults", 10, 3 );
    

Ensure the same callback function, priority, and arguments are used for removal.

Access Premium WordPress Plugins

Got questions or need some help with customization? Reach out to us at WePlugins. We’re here to help!

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.