/ Published in: PHP

This code is usefull for getting the list of Wordpress Sites from Multisite without sending each user id.
Expand |
Embed | Plain Text
// Query for getting blogs $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 ); // put it in array $blogs = $blog_list; // if is valid array echo '<ul>'; // reorder for($i=0;$i<count($array);$i++){ // get data for each id $blog = get_blog_details( $array[$i]['blog_id'] ); // print it } echo '</ul>'; }
You need to login to post a comment.