Created
May 15, 2013 12:56
-
-
Save ericjuden/5583806 to your computer and use it in GitHub Desktop.
WordPress Multisite: List Blogs Alphabetically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(is_front_page()){ ?> | |
<h1>Blog Directory</h1> | |
<?php | |
global $wpdb; | |
$aBlogs = array(); | |
$query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path"; | |
$blogs = $wpdb->get_results($query); | |
echo '<ul>'; | |
foreach($blogs as $blog){ | |
$blog_details = get_blog_details($blog->blog_id); | |
$aBlogs[$blog_details->blogname] = $blog_details->siteurl; | |
} | |
ksort($aBlogs); | |
foreach($aBlogs as $name=>$url){ | |
if($name != ""){ | |
echo '<li><a href="'. $url .'">' . $name .'</a></li>'; | |
} | |
} | |
echo '</ul>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment