I am developing my first wordpress plugin, and i need to get the site name.
The documentation says to use get_current_site_name( $current_site )
function.
Here is my script
myPlugin.php:
$site_data = get_current_site_name( $current_site );
but get_current_site_name() function is not defined yet.
Also there is no global $current_site
variable, as written in documentation.
I also try to add a wp_loaded action, to let the wordpress load fully, but it doesn’t help.
function myfunction() {
global $current_site;
$site_data = get_current_site_name( $current_site );
}
add_action('wp_loaded', 'myfunction');
//Fatal error: Call to undefined function get_current_site_name() in ...
What I’m doing wrong?
Thanks
Update:
There is a bug in this site, when i try to write hello at the top of my question, it strips it automatically. So i’m writing it here – Hello guys 🙂
That function is only available in network mode. It will return the name of the site (the one you use when you create the site), not the title that you set in the options.
You probably want to use
get_bloginfo('name')
. This one returns the site title. Yeah I know, inconsistent naming, global variables …it’s WP 🙂