Roger Stringer   About ▾

I'm Roger Stringer: a father, writer, developer, consultant, chef, speaker. Founder of TheInterviewr.

Blog Archives


~•~
~•~
~•~
~•~
~•~

Video: Scaling WordPress for High-Traffic

 

This video, originally presented by Envato’s Ryan Allen at WordCamp Melbourne is a pretty good listen for learning what your best options are if your wordpress site get hit with massive traffic spikes.

At Envato, Ryan is reponsible for managing (server) performance at some of Australia’s busiest websites. The Envato marketplace network (ActiveDen, ThemeForest, CodeCanyon, AudioJungle, 3dOcean, VideoHive, GraphicRiver and the Tuts+ Marketplace) reached a considerable milestone in October 2010 of a combined membership of 500,000 members around the world, more than double its membership of just one year ago. Managing traffic spikes is crucial as projects get bigger and Ryan will will speaking about what to do when that happens to your WordPress site. If your website gets hit by massive trafic flows what are your best options?

WARNING: SOME LANGUAGE MAY OFFEND, It should also be noted that Ryan has a unique (but hilarious) sense of humor).

Filed Under: Video

~•~
~•~

WordPress: Using multisite domain mapping on a mediatemple grid server

 

This won’t get into setting up multisite in wordpress, but it will help you set up multisite domain mapping on a grid server from media temple. If you need to see a good intro article on setting up multisite mode in wordpress, check this article out or this article for a good multisite .htaccess intro.

First, install WordPress MU Domain Mapping plugin, and follow the instructions for setting that up.

Now, to add a new domain to media temple that will show up on your site, the big catch is to redirect this domain to the existing main domain.

For example, originalsite.com is the main root domain, and I am going to create newsite.com.

  1. Add the domains you’d like to use (newsite.com in this example) as alternate domains in the AccountCenter.
  2. Log into your (gs) via SSH, move into the domains directory and delete the folders for newsite.com with these commands:

    cd domains rm -rf newsite.com
    
  3. Create a symlink named ‘newsite.com’ that points at the originalsite.com folder with this command:

    ln -s originalsite.com newsite.com
    

This will now have newsite.com pointing to originalsite.com, which thanks to the domain mapping plugin above, you will see the new site show up when you run it. I tried to make this sound as straight forward as I could, so I apologize if it ended up being more complex.

Filed Under: Articles

~•~

Quick Function: Check for parent category in wordpress

 

When I was working on foodjumper, there were times when I wanted to check the parent category, for example, if you’re in the Dinner category or viewing a post in that category, I want to display the proper layout for posts in the Recipes category. One function that works, is to do a check like this:

function parent_category( $cats, $_post = null ){
    if( is_string($cats) )  $cats = get_cat_ID($cats);
    foreach ( (array) $cats as $cat ) {
        $descendants = get_term_children( (int) $cat, 'category');
        if ( $descendants && in_category( $descendants, $_id ) ) return true;
    }
    return false;
}

WordPress published a similar function on their site, but it used the actual category ID in the function. I found it easier to let you enter the slug instead. Now, when you want to check if a post is in a category that is a child, you can do a check like this:

if(in_category('recipes') || parent_category('recipes') ): 
    // display this post as a recipe
else: 
    // display this post as a normal post
endif;

This can be adapted to almost any type of similar treatment, I just used recipes above as an example since it’s where I just used this function.

Filed Under: Code

~•~

Quick Function: Inserting ads into your RSS feeds in WordPress

 

On my main wordpress site (this one your reading now), I like to display a single line below each RSS feed item that tells people quickly about some of my other sites. The ad appears like this:

The code for it is pretty straight forward, and can also be used to display a copyright message linking to your site, or anything along those lines. Place the following code in your theme’s functions.php file:

function insertAds($content) {
    if(is_feed()) {
        srand((float) microtime() * 10000000);
        $banners = array();
        $banners[] = 'Banner number 1. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
        $banners[] = 'Banner number 2. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
        $banners[] = 'Banner number 3. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
        $banners[] = 'Banner number 4. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
        $rn = array_rand($banners);
        $content = $content.'<hr />'.$banners[$rn];
    }
    return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content', 'insertAds');

You could also replace this with banner images. Anyway, what this does is randomly select which text to display on your rss feed items. So for each article, you could have a different ad appearing. If you wanted to use this to display only one message (like a copyright), you’d use this version:

function insertMsg($content) {
    if(is_feed()) {
        $banner = 'You are reading my blog. <a href="http://www.linktoblog/" target="_blank">Name of your blog</a>';
        $content = $content.'<hr />'.$banner;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'insertMsg');
add_filter('the_content', 'insertMsg');

That’s it, like I said, it’s a quick function, but it serves it’s purpose.

Filed Under: Code

~•~