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

How to use manage_sites_custom_column action in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
June 2, 2023
5 minutes read

You know, working with WordPress hooks can be quite the adventure, especially when you’re diving into something like manage_sites_custom_column. It’s like adding your own little magic touch to the Sites list table, and trust me, once you get the hang of it, you’ll be customizing WordPress like a pro! Let’s explore this hook together.

Example 1: Adding Custom Data to a Column

Imagine you want to display some custom data in one of the columns of your Sites list. This example shows how you can hook into manage_sites_custom_column and add your own content.

function weplugins_add_custom_data_to_site_column($column_name, $blog_id){
    if($column_name === 'your_custom_column'){
        echo 'Custom Data for Site ID ' . $blog_id;
    }
}
add_action("manage_sites_custom_column", "weplugins_add_custom_data_to_site_column", 10, 2);

Example 2: Displaying Site Metadata

Let’s say you want to show some metadata related to each site. This example demonstrates how to fetch and display that information using the hook.

function weplugins_display_site_metadata($column_name, $blog_id){
    if($column_name === 'site_metadata'){
        $meta = get_blog_option($blog_id, 'your_meta_key');
        echo $meta ? $meta : 'No metadata found';
    }
}
add_action("manage_sites_custom_column", "weplugins_display_site_metadata", 10, 2);

Example 3: Removing a Custom Column Action

At times, you might need to remove an existing action that uses this hook. Here’s how you can do it.

function weplugins_modify_site_columns(){
    remove_action("manage_sites_custom_column", "weplugins_display_site_metadata", 10, 2);
}
add_action("init", "weplugins_modify_site_columns");

If you’re ever stuck or need some help customizing your site with this hook, feel free to reach out to us. Our team is here to help you make your WordPress site truly yours!

Contact Us for customization inquiries.

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.