$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - get_current_site() is undefined|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - get_current_site() is undefined

matteradmin9PV0评论

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 ) ) {

}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far