This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
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.
Got questions or need some help with customization? Reach out to us at WePlugins. We’re here to help!
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.