Answer the question
In order to leave comments, you need to log in
Wordpress Multisite - how to execute code for only one site?
How to write code in functions.php (calling some function) so that it is executed only for a specific network site ID?
Similarly - how to call a php variable on one site from another network site (for example, the main one)?
Answer the question
In order to leave comments, you need to log in
Code isolation for one site:
global $blog_id;
if( $blog_id == 1 ) {
// код, который должен выполняться только для сайта с ID=1
}
// или
$blog_id = get_current_blog_id();
if( $blog_id == 1 ) {
// код, который должен выполняться только для сайта с ID=1
}
$blog_id = 2;
switch_to_blog( $blog_id );
// Выполнить нужные действия
restore_current_blog();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question