Fun with WordPress -Blog Types Plugin

Posted on October 31st, 2011 by

4


For awhile now I have been looking for a way to categorize sites on a WordPress Multi-site installation. This would allow for easy listing of all of the sites on a network. For example, if a school had a separate web-site for each class, they could have a home-site that not only listed each class but could group those classes by subject, or grade-level or however else they needed.

There could also be many other uses if this idea. A home-site that listed all of the sub-sites on the network by an easy to use taxonomy, much in the same way you can now create custom taxonomies with custom post-types.

I thought I had finally found a way to do this through a plugin called Blog-types, created by the team at WPMUDev.org; however, the plugin is sort of half-baked. Although the basic functionality works (it does create a way for you to add categories and even sub-categories to each of your sites), it does not provide a way to easily access those categories. So unless you are a dev, you will be kind of stuck on how to make those categories work for you.

If you have been trying to figure out how to use the Blog Types plugin, then you already know all of this, and probably found this page googling around for a solution.
I, with my puny PHP skills, decided to try my hand at writing a few functions to access these categories so that this plugin might actually be useful. So far I have managed to eek out a function that will return a list of each of the site categories, with a list under each one of the sites that are within that category.

I am currently working on another function that will list the sub-categories with links to all of the sites under each sub-category. These functions will be able to be added to a page template.

Once I have the code ironed out I will turn it into a plugin for ease of use…

++++++++++++++++++UPDATE ON 11-22-2011++++++++++++++++++++++++++++

 

Okay…After some requests I have just bundled the Blogs-Type plugin along with my additional file I created. You can download it here:

blog-types

Once you have downloaded:

IF YOU ALREADY HAVE BLOG_TYPES PLUGIN INSTALLED:

then just go into the zip and get the file called get-blog-types.php and put it into your plugins folder and network activate.

IF YOU DO NOT HAVE BLOG_TYPES PLUGIN INSTALLED:

Then unzip the folder and place the entire folder into your plugins directory and then network activate the Blogs-Type plugin in WordPress. That will activate everything.
Please bear in mind that you have to go into the blog-types-config.php file and manually add the Blog-Types and Sub-Types you want to use. Currently I have it set to use names of Counties and Cities in my area.

 

Once you have activated the plugin, you can then add something like this to your page template where you want to show the list of categories and sites:

 

++GET BLOG TYPES++
<div id=”sites”>
<h3 class=”pagetitle”>A List of Blog-Types</h3>
<?php blog_types_list(); ?>
</div><!– /sites –>

++GET BLOG TYPES WITH SITES++
<div id=”sites”>
<h3 class=”pagetitle”>A List of Blog-Types and Sites</h3>
<?php get_blog_types(); ?>
</div><!– /sites –>

++GET BLOG SUB-TYPES (just a list of available sub-types)++
<div id=”subtypes”>
<h3 class=”pagetitle”>A List of Sub Types</h3>
<?php blog_subtypes_list();; ?>
</div><!– /subtypes –>

++GET BLOG SUB-TYPES with related sites++
<div id=”subtypes”>
<h3 class=”pagetitle”>A List of Sub Types with related Sites</h3>
<?php get_blog_subtypes(); ?>
</div><!– /subtypes –>

 

This last one someone requested so they could add it to Google Analytics code on each site. It displays the blog-types for current site separated by dashes.
<?php current_blog_types(); ?>

 

will output: calaveras-tuolumne

 

 

 

I am open to feedback on ways to modify this, but I wanted to make it available in case anyone wanted to give it a try or modify it.