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

How to use manage_this-screen-id_sortable_columns filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
March 15, 2023
5 minutes read

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.

Access Premium WordPress Plugins

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.