get_sites()
最后更新于:2021-11-27 00:18:14
get_sites( string|array$args=array())Retrieves a list of sites matching requested arguments.
参数
- $args
-
(string|array) (Optional) Array or string of arguments. See GC_Site_Query::__construct() for information on accepted arguments.
Default value: array()
响应
(array|int) List of GC_Site objects, a list of site IDs when ‘fields’ is set to ‘ids’, or the number of sites when ‘count’ is passed as a query var.
源文件
文件: gc-includes/ms-site.php
function get_sites( $args = array() ) {
$query = new GC_Site_Query();
return $query->query( $args );
}
// GeChiUI 4.6 // if ( function_exists( 'get_sites' ) && class_exists( 'GC_Site_Query' ) ) { $sites = get_sites(); foreach ( $sites as $site ) { switch_to_blog( $site->blog_id ); // do something restore_current_blog(); } return; } // GeChiUI < 4.6 // if ( function_exists( 'gc_get_sites' ) ) { $sites = gc_get_sites(); foreach ( $sites as $site ) { switch_to_blog( $site['blog_id'] ); // do something restore_current_blog(); } return; }