Listing your networked blogs



One of the benefits of running WordPressµ is the ability to have a centralized blog hub with many subordinate blog spokes. In the adult web community a central site caters to each niche by specific blog. For example, a central porn hub can link to niches, such as blowjobs, lesbians, etc. This tip allows you to automatically list those blog spokes on whichever page(s) you desire.

In order to create the list, we need to know what information we want included in that list. We obviously need the name of each blog so our readers know what they are selecting. We need the URL of each blog so that we can redirect our readers to the right blog. And lastly, we need the description of each blog so that we can construct an SEO friendly link.

WordPress has a couple of built-in functions that we will use to accomplish this task.

The first function is called, get_blog_list(). This function returns an array of arrays containing blog information for each blog hosted by this WordPressµ install.

This function takes two parameters, a starting number, and the number of blogs to return information about. We will need to start our blog inquiry at position 0 (zero), the first blog. Referring to the documentation, we can use the keyword, 'all', as the second parameter. These two parameters will return information about all of our blogs. Our function call will look like the following:

<?php
$blog_list = get_blog_list( 0, 'all' );
?>

The get_blog_list() function returns certain information about our blogs in the form of arrays. The specific return value we are interested in is the blog_id. This, in turn, is passed to another built-in function, called get_blog_option(), to get the specific information we require.

To iterate through the array, we will use the foreach statement, like this:


<?php
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
}
?>

The foreach statement allows us to look at each array element to extract the data we need in order to construct our list. We now need to construct our list from the information contained in each array element. The elements, as we stated above, are the name, description, and URL of each blog. These elements are used to construct our list, as follows:

<?php
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
echo '<li><a href="'.get_blog_option($blog['blog_id'],'siteurl').'" title="'.get_blog_option($blog['blog_id'],'blogdescription').'" target="_blank">'.get_blog_option($blog['blog_id'],'blogname ').'</a></li>'."\n";
}
?>

The resulting code segment above should be placed within whatever theme formatting your site requires. Usually this information is placed within the sidebar of a site, but that is entirely up to you.

Leave a Reply

You must be logged in to post a comment.


Advertisement

Popular Posts

Sponsor Ad Management User Guide

The cd_ad_sponsor plug-in was written to manage the sponsor ads that can be presented with

A WordPress Sponsor Ad Management Plug-In

I wrote the WordPress Sponsor Ad Management Plug-in to use within the WordPress and WordPr

Quote of the day plugin

The Quote Of The Day plug-in manages quotes displayed on your WordPress or WordPressµ

Quote Of The Day
Many a small thing has been made large by the right kind of advertising.
~Mark Twain