List of WordPress Multisites (MU) Blogs

// 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 ) );
// 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>';

Displaying only immediate children (only one level) pages using get_pages() function

Displaying only immediate children (only one level) pages in WordPress. For example, I have page and sub page structure like:

Page 1
  Page 11
     Page 111
     Page 112
  Page 12
  Page 13
Page 2
  Page 21
  Page 22
     Page 221
     Page 222

Let’s suppose, you need to list all children pages of Page 1, i.e. Page 11Page 12Page 13. But you don’t want to be listed Page 111Page 112 and so on which is WordPress’s default behavior.

Let us assume that ID of Page 1 is 5 then:

$result = get_pages('child_of=5&hierarchical=0&parent=5);

Notice the child_of and parent must have same value. This function will get only three page – Page 11Page 12Page 13 and not Page 111, Page 112 and so on.

WordPress Pagination without plugin

The default WordPress pagination only comes with the “Older posts” and “Newer posts” links at the bottom of the page when you want to navigate to the older entries. This works fine for sites with few entries, but isn’t very user-friendly for blogs and sites with dozens or even hundreds of pages worth of entries. To enable your visitors to quickly navigate your site and browse through your content from page to page, a list of numbered pages would be more useful, like Google’s search results.


Add the following function to your functions.php file:
Continue reading

Pagination: Split WordPress Post into Multiple Pages

This simple trick will let you split a single page or post into multiple pages. Just switch to the “Text” screen in your editor, and then add the following code wherever you’d like to add the paging.

Continue reading

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' );
 foreach ($blog_list AS $blog)
     echo 'Blog '.$blog['blog_id'].': '.$blog['domain'].$blog['path'].'<br />';

and you’re all done !!

404 error in accessing child theme in wordpress multisite

If you are using IIS Server and need to install wordpress multisite. Click here for the installation process.

After installing the multisite when you create a child theme, there might be a problem you are getting 404 error. It means the path you are trying to access on your web browser is not able to redirect to the specified directory. It is the problem for redirection. In this case just update your web.config if you are using the Windows IIS Server or update the .htaccess file if you are using the apache/linux Server.

Code for web.config file:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                </rule> Continue reading