WordPress Development Tricks – Independent Blogs per Category

WordPress Tips and TricksWith its extreme flexibility and proven prowess as a publishing platform, WordPress has become an invaluable tool in the arsenal of most web developers. However, advanced customization is often cumbersome and can be difficult to achieve.

Having spent several hours the past two days fighting against WordPress’ limited support for splitting blogs by category, I’m sharing a few of the insights gained during the arduous process.

If a website has multiple domains, an alternate technology called Multisite or Network mode. This, however, changes the blog structure and creates a high degree of separation between blogs. My needs were more simple – I wanted to create two categories – and have one subfolder on my site display the posts from that category, and another subfolder display the posts from the other category. I wanted the two categories to be separate, in everything from their breadcrumbs, to archives, to forward / next buttons.

Initial research showed this to be challenging. Most posts online claimed this was not possible. With a few meta-level tweaks to WordPress, however, the solution quickly became apparent.

There are two primary components – changing “wp-blog-header.php” to redirect to the correct section of the site based on the post ID, and then changing each listing page (category, author, archive, and tag) to show the correct header based on the subfolder / high level category. Finally, the wp-config will need to be updated to change the WP_HOME variable based on the subfolder.

PHP Server Variables can be used to find the current subfolder based on the Request URI. Combining this with filtered calls to query_posts above each post listing makes the rest a simple exercise.

Note: Two custom filter hooks did need to be added in order to properly list the monthly archives. Since the call to get archive does not have parameters for monthly filters, manual joins against the database need to be executed.

All in all, I’m satisfied with the blogs. I can keep one common codebase and theme for both blogs in order to minimize maintenance, and take advantage of any enhancements made.

As a bonus, I implemented excerpts throughout the blog, making the post listing more straightforward. Although WordPress can be difficult to customize, its large user base and open source model make even advanced customizations relatively straightforward.

Written by Andrew Palczewski

About the Author
Andrew Palczewski is CEO of apHarmony, a Chicago software development company. He holds a Master's degree in Computer Engineering from the University of Illinois at Urbana-Champaign and has over ten years' experience in managing development of software projects.
Google+

RSS Twitter LinkedIn Facebook Email

3 thoughts on “WordPress Development Tricks – Independent Blogs per Category”

  1. I’m amazed, I have to admit. Seldom do I come across
    a blog that’s both equally educative and entertaining, and without a doubt, you’ve hit the nail on the
    head. The issue is an issue that too few people are speaking intelligently about.
    Now i’m very happy I found this in my search for something regarding this.

Leave a Reply

Your email address will not be published. Required fields are marked *