Wordpress: Use PHP Function based on Blog URL & Adding To MU-Plugins

I am developing a plugin for an MU site. The MU site has about a few hundred blogs, but there are three types of blogs and they are named as:

blogname/sportstype1 blogname/sportstype2 blogname/sportstype3 blogname/celebritytype1 blogname/celebritytype2 etc.

I need to make two functions, one for type1, and the other function for the rest (type2/3). I have a function I made, wanted to ask is this the right/best way to do this:

    $whatistype = <?php get_bloginfo('site_url'); ?>
    $type = <?php substr( $whatistype, -4);
    <?php if ( $type == "type1 ) 
{ include 'type1list.php'; 
   /* Or code */


{ include 'typelistother.php
    /* Or code */

Also, I would want this to run only when a blog is created. I will check under the hood at Cets Default plugin, but would it be best to make this a plugin and activate sitewide or make into an MU-plugin? How would I go about making a plugin for the mu-folder (can't find much documentation on it).


This is the best article that I've seen on making plugin for MU. Not sure how much has changed since Wordpress 3.x however. For instance the wp-plugin/muplugins/ directory seems to be gone in the Wordpress 3.1 that I am using.

I would create a MU plugin with a function that is hooked onto wpmu_new_blog.

function my_custom_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
     // depending on if you're using subdomains or sub-directories,
     // match against $domain or $path respectively for 'type'
add_action('wpmu_new_blog'), 'my_custom_new_blog', 10, 6);

Just create a PHP file, name it what you like, throw in the standard WordPress plugin headers (not required, purely for information in the plugins admin screen) and then drop it in the root of wp-content/mu-plugins.

If you want to break up your code from a single file, place everything inside wp-content/mu-plugins/my-directory - anything in there won't be touched by WP - but keep your single PHP file still in the root, using it to load the rest of your code when it needs it.

Need Your Help

How do I register ZF2 Helpers with zfc-twig 1.2?

php zend-framework2 twig

I've had to downgrade from 1.2 to 1.1.5 to get my view helpers to work again.

Apache, LocationMatch: match query string

apache query-string locationmatch

How can I match a query string using LocationMatch with apache?