如果需要在 WordPress 多站點的子站中的任何子站,執行任何功能,看嘗試使用下面的程式碼段進行開發工作。
/** * Perform any function on any site on the network * * @param integer $site_id site on which to perform the function * @param string|array $action function name to perform * @param array $args parameters passed as an indexed array * @return */ function do_network_request( $site_id, $action, $args = array() ) { switch_to_blog( $site_id ); if ( ( is_string( $action ) && function_exists( $action ) ) || ( is_array( $action ) && method_exists( ...$action ) ) ) $result = call_user_func( $action, ...$args ); else $result = NULL; restore_current_blog(); return $result; } // end do_network_request