get_blog_list

Deprecated functionality to retrieve a list of all sites.

Description

get_blog_list( (int) $start = 0, (int) $num = 10, (string) $deprecated = '' ); 

Parameters (3)

0. $start — Optional. (int)
Offset for retrieving the blog list. Default 0.
1. $num — Optional. (int) => 10
Number of blogs to list. Default 10.
2. $deprecated — Optional. (string) => ''
The deprecated.

Usage

  1. if ( !function_exists( 'get_blog_list' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-deprecated.php'; 
  3.  
  4. // Optional. Offset for retrieving the blog list. Default 0. 
  5. $start = -1; 
  6.  
  7. // Optional. Number of blogs to list. Default 10. 
  8. $num = 10; 
  9.  
  10. // The deprecated. 
  11. $deprecated = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = get_blog_list($start, $num, $deprecated); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-deprecated.php  
  1. function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) { 
  2. _deprecated_function( __FUNCTION__, '3.0.0', 'wp_get_sites()' ); 
  3.  
  4. global $wpdb; 
  5. $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A ); 
  6.  
  7. $blog_list = array(); 
  8. foreach ( (array) $blogs as $details ) { 
  9. $blog_list[ $details['blog_id'] ] = $details; 
  10. $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" ); 
  11.  
  12. if ( ! $blog_list ) { 
  13. return array(); 
  14.  
  15. if ( $num == 'all' ) { 
  16. return array_slice( $blog_list, $start, count( $blog_list ) ); 
  17. } else { 
  18. return array_slice( $blog_list, $start, $num );