I need to list all current WordPress Multisite Blogs apart from the one the user is on and the main blog. We have a 404 page where we'd like to recommend other blogs (physical places) apart from the blog the user is current on and the main blog.
Here is our structure:
Main Blog (places) Blog 1 (New York) Blog 2 (London) Blog 3 (Paris)
I can list all blogs but need to remove the main blog and the one the user is cirrently on from the list.
<?php
$bcount = get_blog_count();
global $wpdb;
$blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE
spam = '0' AND deleted = '0' and archived = '0' and public='1'"));
if(!empty($blogs)){
?><ul class="menu"><?php
foreach($blogs as $blog){
$details = get_blog_details($blog->blog_id);
if($details != false){
$addr = $details->siteurl;
$name = $details->blogname;
if(!(($blog->blog_id == 1)&&($show_main != 1))){
?>
<li class="menu-item<?php if($counter == get_current_blog_id()){ echo ' current-menu-item';}?>">
<a href="<?php echo $addr; ?>"><?php echo $name;?></a>
</li>
<?php
}
}
}
?></ul><?php
} ?>
Thanks