Two WordPress blogs, one site

Technology Blog

[ Edited 8th June 2008: I’m not doing it this way any more. Read this more recent post for the lowdown. ]

It’s a frequently asked question – how do you get multiple blogs from a single installation of WordPress? And the answer is surprisingly simple, if a little technical.

I wanted to use a blog for this site’s portfolio page. I already had WordPress installed, obviously, so I didn’t want to install a second copy and have to maintain it in parallel. That seemed stupid.

I read the WordPress page about multiple blogs and was inspired to make my own attempt. My solution, unlike similar ones linked from that page, does not involve symbolic links: my hosting does not permit them, and anyway I realised they aren’t actually necessary.

To start with I made a new directory “portfolio” and put a new index.php file in it. This index.php is like the standard WordPress one except that it loads the rest of the code from the “journal” directory instead of the local one. The change to do this involves only one line of code.

At this point you can run this PHP file and see it load the same blog as in the normal directory, which is rather useless but shows all is well.

WordPress needs to detect the directory it’s being invoked from and select its database settings accordingly: the code for this goes into config.php. I chose to set it up so that if it’s invoked from the “portfolio” directory a different table prefix is used.

Running the PHP file now from “portfolio” gives a different result: it is suggested that you run the install script to create the database tables for your new blog. But if you attempt to do so you’ll be disappointed as it returns a 404 not found error.

This is because only the index.php is present in the portfolio directory: all the other scripts such as the administration and installation ones are elsewhere. But this problem can be solved very easily on an Apache site: with a custom .htaccess file you can send all requests for any file except index.php to the “journal” directory instead.

Once that’s working the only remaining task is to theme your new blog. If you use a completely different theme to your existing one, there’s no problem, but if you want, as I did, to use the same theme with a few minor variations then you’ll need to insert tests for the request directory into your theme code.

(If anyone wants the code for this solution I’m happy to supply it — after I’ve tidied it up a little. Just let me know.)

19 Responses to “Two WordPress blogs, one site”

  1. Ant Brown

    Hi there,

    I would like to know the code snippets you used for this, I’m not worried if it’s untidy.

    Thanks for your help,

  2. Alfred Armstrong

    OK, Ant, here goes:

    In the home directory for my new blog, I created an index.php like this, pointing to my existing blog directory:

    define('WP_USE_THEMES', true);

    In the same directory I created a .htaccess to route other requests to the existing blog:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/portfolio$
    RewriteRule . /portfolio/ [L,R=301]
    RewriteCond %{REQUEST_URI} !^/portfolio/$
    RewriteCond %{REQUEST_URI} !^/portfolio/index.php$
    RewriteRule ^(.+) /journal/$1

    Then I edited wp-config.php so it specified a different table prefix for my new blog, changing the assignment of $table_prefix to this:

    if(substr($_SERVER['REQUEST_URI'], 0, 10) == '/portfolio') {
      $table_prefix = 'pf_';
    } else {
      $table_prefix  = 'wp_';   

    At that point I requested the new blog and got the installation dialog. After following it my new blog was basically ready, except for its theme. I wanted to re-use most of the existing theme, so I simply edited the files to test the global $table_prefix wherever I wanted different output.

    For just two blogs this approach is OK. I’d tidy it up before I added any more.

  3. YWAMdan

    Hey Alfred. Groovy solution.

    I just installed WordPress twice in order to get 2 databases in 1 site. And then I saw your solution. Which gets me to wondering… Why don’t you have a link to your Portfolio page in your top navigation menu?

    Is there a way to dynamically “inter-link” these so that this main site links correctly to the /portfolio/ page and the /portfolio/ menu links back to this main site? Or must one use static, plain html links?


  4. Alfred Armstrong

    Dan, my menu is hard-coded rather than generated by WordPress; the absence of the portfolio link is for historical reasons – and probably should be fixed.

    Your question is a good one. Making the two areas aware of each others menus would be tricky, though not impossible. A plugin which produced a composite menu would seem like a good answer.

    One flaw in my solution I didn’t mention above, but discovered since, is that you need to be careful not to let WordPress write to the .htaccess file once it is set up – it can break things! So I set mine as read-only, which means somewhat more effort when a change is required.

  5. Kathleen

    Ooh, this looks like just what I’m looking for. I was worried what I wanted might not even be possible, but then I realised that somewhere out there someone would have written it and it looks like I was right 🙂

    Shall have to give it a try over the weekend. Thanks very much for sharing your code.


  6. Kathleen

    Thanks for responding and for the offer of help, Alfred.

    At first I wanted to try this with an existing blog, where the WP installation is at the root level (well, it’s in the public_html folder, does that count?), so I tried to edit the .htaccess to point to the root, but I must have got that wrong as I got 404 errors.

    So now I’ve started afresh with a new installation at another domain, for testing purposes, the original at, with the ‘portfolio’ one being However, both are showing the same blog – which is the wordpress one. I looked at the database and only wp_ tables have been created. So it looks like I’ve somehow got errors in my tvt .htaccess and/or my wordpress wp-config.php files Aagh!

    Am close to giving up as I’m in way over my head and don’t want to be bugging you with numerous requests to help, especially when I’m so clueless. Would be great if it’s something small I’ve managed to miss by some n00b oversight…!

    Thanks again,


    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/tvt$
    RewriteRule . /tvt/ [L,R=301]

    RewriteCond %{REQUEST_URI} !^/tvt/$
    RewriteCond %{REQUEST_URI} !^/tvt/index.php$
    RewriteRule ^(.+) /wordpress/$1

  7. Alfred Armstrong

    Kathleen, I bet the problem’s in wp-config.php, which didn’t show up due to its content being filtered out. You’d need to run it through a converter to turn it safely into HTML entities (as I did with the code I posted). It’d be quicker if you simply emailed me the files, to alfred (at) likemind (dot) co (dot) uk.

  8. Joe

    This is a great bit of code, great explanation and it works like a charm. Thanks!

  9. Awk

    I have istalled wordpress twice to 2 of its own folders (for 2 seperate blogs)in public html folder, the 1st blog worked well with permalink code being edited in the htaccess file fine, now I have added my second install for my second blog I can’t get pretty permalinks to work etc. My htacces file resides at root of my public html foder but outside both of my blog installs. Like I said all works fine on the first blog, but not on the 2nd once its installed. Is there some code I need to put in the htaccess file or similar please.


  10. Jules

    Awesome, Alfred! Thanks a lot for sharing this!

    Here’s a question, though: how would I include the_excerpt of my second blog into the sidebar of the first one? I mean – sure this is possible with a few lines of proper php, but I was wondering if there is a way to use the comfy WordPress shortcuts. The way I see it, I would have to tell the_excerpt where to look in this special case without screwing up search results or archives overwiews in the first blog… Tricky? Or doable? I have no clue where to start. 🙂

    Thanks again!


  11. Alfred Armstrong

    Jules, thanks for your comment. I don’t use this approach any more, preferring to use categories to separate the different blogs. This blog, my portfolio and the articles section of this site are all really a single blog with three categories of content.

    I find this to be a much more flexible solution.

  12. Natalie

    Jules, I’m not sure if I understand exactly what you’re wanting to do, but in WordPress, I’ve put an RSS widget into my side bar, and filled it in with the feed URL from another site of mine. This way, every time I update Site A blog, it shows up in the side bar of Site B. I’m not sure if it will allow for partial view, but hope this helps.

  13. Chad

    I was trying to make my main blog page look different then a category blog page and with different content. Virtually I wanted two blogs on one wordpress site. This plugin helped me get the job done. I would recommend three plugins that helped me to get the job done: Advanced Category Excluder, Widget Logic, and Redirection. It was a matter of being able to exclude certain posts from our main blog page (Advanced Category Excluder) then being able to exclude sidebar menu widgets from certain categories (Widget Logic). The Redirection plugin allowed to direct the blogs category link that is part of our theme back to the main blog page.

    I hope these plugins will help someone else out. If you are curious about what it looks like then check out (this is a category page) and (this is our main blog page).

  14. AfroeuroBoy

    Though this post is old. It was really helpful in helping me find a solution on how to have to blogs on one WordPress installation. Thanks a lot!!!

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>