List of Wordpress Multisites (MU) Blogs


<?php
// 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
foreach ( (array) $blogs as $details )
{
$blog_list[ $details['blog_id'] ] = $details;
}
unset( $blogs );
$blogs = $blog_list;

// if is valid array
if (is_array( $blogs ) )
{
echo '<ul>';
$array= array();
// reorder
$array= array_slice( $blogs, 0, count( $blogs ) );
for($i=0;$i<count($array);$i++)
{
// get data for each id
$blog = get_blog_details( $array[$i]['blog_id'] );
// print it
echo '<li><a href="'.$blog->siteurl.'">'.$blog->blogname.'</a></li>';
}
echo '</ul>';
}
?>
Advertisements

Return a list of sites on the wordpress multisite network


A simple function that returns the list of all wordpress child websites in the network. The code below just shows all the URL and unlinked.

 $blog_list = get_blog_list( 0, 'all' );
 krsort($blog_list);
 foreach ($blog_list AS $blog)
 {
     echo 'Blog '.$blog['blog_id'].': '.$blog['domain'].$blog['path'].'<br />';
 }

and you’re all done !!

Install WordPress with Multiple Domains or Subdomains


To change WordPress from the standard single site install to a WordPress Multisite which allows you to create a network of sites you need to:

  1. Update your wp-config.php file.
  2. Choose the structure of your Multisite in terms of whether you want to use sub-domains or sub-directories.
  3. Add the extra lines your WordPress installation generates into your wp-config.php.
  4. Add the generated mod_rewrite rules to your .htaccess file, replacing other WordPress rules.

You do this as follows:

Updating your wp-config.php file

  1. Locate your wp-config.php file on your hard drive.
  2. Open your wp-config.php file for editing.
  3. Add the following line to your wp-config.php file:
define('WP_ALLOW_MULTISITE', true);

above where it says /* That’s all, stop editing! Happy blogging. */: Continue reading