Functions can be found at http://codex.wordpress.org/WPMU_Functions
Code to get any blog pages by blog id as below:
switch_to_blog( $blog_id );
$pages = get_pages($args);
foreach ( $pages as $page ) {
echo $page->post_title;
}
restore_current_blog();
Code to get all the blogs in current site:
global $wpdb;
$blogs_info = array();
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' AND mature = '0' AND public = '1'";
$site_blogs = $wpdb->get_results($wpdb->prepare($query)); // get all subsite blog ids
if(count($site_blogs) > 0) {
foreach( $site_blogs AS $site_blog ) {
$details = get_blog_details($site_blog->blog_id);
}
}
Code to get any blog pages by blog id as below:
switch_to_blog( $blog_id );
$pages = get_pages($args);
foreach ( $pages as $page ) {
echo $page->post_title;
}
restore_current_blog();
Code to get all the blogs in current site:
global $wpdb;
$blogs_info = array();
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' AND mature = '0' AND public = '1'";
$site_blogs = $wpdb->get_results($wpdb->prepare($query)); // get all subsite blog ids
if(count($site_blogs) > 0) {
foreach( $site_blogs AS $site_blog ) {
$details = get_blog_details($site_blog->blog_id);
}
}
No comments:
Post a Comment