Created
September 1, 2021 11:11
-
-
Save yratof/1e16da7e375c0a1bc278fb46e9bcf7c0 to your computer and use it in GitHub Desktop.
Show the site_name on sites.php with multisite wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add site_name as a column */ | |
add_filter( 'wpmu_blogs_columns', 'add_useful_columns' ); | |
function add_useful_columns( $site_columns ) { | |
$site_columns['site_name'] = 'Site Name'; | |
return $site_columns; | |
} | |
/* Populate site_name with blogs site_name */ | |
add_action( 'manage_sites_custom_column', 'column_site_name' , 10, 2 ); | |
function column_site_name( $column_name, $blog_id ) { | |
$current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) ); | |
echo ucwords( $current_blog_details->blogname ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment