php - get_current_site() is undefined

admin2025-06-02  1

I get the error Fatal error: Uncaught Error: Call to undefined function get_current_site() in XXXXXXXX
Why is this happening? Do I need to load something before I can use that function? Is my Installation wrong?

Thanks in advance

PS: my Code (if you need it)

$f = function () {     
    ob_start();    
    var_dump(get_current_site());   
    file_put_contents(__DIR__ . '/dump.html', ob_get_clean());  
return;  
// I actually want to put styles here later, which change with every page  
};  
add_action('wp_enqueue_scripts', $f);  

I get the error Fatal error: Uncaught Error: Call to undefined function get_current_site() in XXXXXXXX
Why is this happening? Do I need to load something before I can use that function? Is my Installation wrong?

Thanks in advance

PS: my Code (if you need it)

$f = function () {     
    ob_start();    
    var_dump(get_current_site());   
    file_put_contents(__DIR__ . '/dump.html', ob_get_clean());  
return;  
// I actually want to put styles here later, which change with every page  
};  
add_action('wp_enqueue_scripts', $f);  
Share Improve this question asked Mar 1, 2019 at 9:21 A new 1A new 1 93 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

get_current_site() is a function for getting the current Multisite Network. As with other multisite-related functions, it is not available to use if your site is not configured as a multisite network.

I can't tell from your code what you're attempting to use the function for, so I can't offer a suggestion for what to use instead.

If you want to check if you're on a specific page you can use is_page() along with the slug of ID if the page you're checking for:

if ( is_page( 'about-us' ) ) {

}

if ( is_page( 5 ) ) {

}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748851917a314255.html

最新回复(0)