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.
Ever wondered how you can customize WordPress to fit your specific needs? Hooks are your best friend! Let’s dive into the manage_this-screen-id_sortable_columns filter. This is an amazing hook that lets you modify the sortable columns on a screen in WordPress. The dynamic part, $this->screen->id, represents the current screen’s ID. You can register this filter using add_filter
in your theme’s functions.php
or a custom plugin. It’s always a good idea to create a custom plugin so your changes persist even after theme updates.
Example 1: Making the Title Column Non-Sortable
Here’s a simple example of how you can use the hook to make the title column non-sortable in the posts screen.
add_filter( 'manage_edit-post_sortable_columns', 'weplugins_slug_title_not_sortable' ); function weplugins_slug_title_not_sortable( $cols ) { unset( $cols['title'] ); return $cols; }
Example 2: Customizing Sortable Columns
Below is an example of how to use this hook to customize the sortable columns according to your needs.
function weplugins_modify_manage_this_screen_id_sortable_columns_defaults($sortable_columns) { // Update the $sortable_columns as needed. return $sortable_columns; } // Add the filter add_filter( "manage_this-screen-id_sortable_columns", "weplugins_modify_manage_this_screen_id_sortable_columns_defaults", 10, 1 );
Example 3: Removing the Hook Callback
If you need to remove a registered hook, you can use the following code snippet. Remember to provide the same callback function name, priority, and number of arguments.
remove_filter( "manage_this-screen-id_sortable_columns", "weplugins_modify_manage_this_screen_id_sortable_columns_defaults", 10, 1 );
Feel free to reach out if you have any questions or need some customization help. Check out our Contact Us page for more info.
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.