Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am building a classifieds website and am using Wordpress for the functionality of user accounts, Paypal integration, custom taxonomies and of course super flexible custom post types for the listings.

I would like to be able to map a subdomain to a particular sub-site. For example: australia.somesite.com or brisbane.somesite.com and have it localise the site to that particular region.

Is there a clean-cut way of doing this with Wordpress, possible that someone else has surely already done this.

share|improve this question
    
what do you mean clean cut way? it seems like you already figure everything out. To use custom post types connect to the categories and tags. Have different users create the data when they log in to the backend. So what exactly is needed other than the code? :) –  David Chase Mar 7 '13 at 1:57
    
You misunderstand. I know what I want to do, I know how I want the site to work but the best and cleanest way possible to give the appearance of a localised site (complete with localised logo). How would I map a subdomain to a category in Wordpress and have it only show those categories contents as well as only post a listing to that location? Listings will be added via a custom front-end form, not from the backend. –  DigitalSea Mar 7 '13 at 2:39

2 Answers 2

up vote 1 down vote accepted

Sort of a vague question, but I think I understand what you're getting at. You'd need to use a Wordpress Multisite installation, which will effectively create localized blogs on a subdomain (brisbane.example.com, perth.example.com).

Using a single site Wordpress installation to do this is possible, using CNAME mapping on the domain, however this would not suit your goal as you won't be able to post within the localized listing.

To achieve the subdomain for category "effect", with the least amount of effort, you should use Multisite. I hope that answers your question.

A good rundown of getting Multisite going can be found at WPMUDEV. Hope this helps.

The Wordpress.org version can be found at: http://codex.wordpress[DOT]org/Create_A_Network

And this is the last bit of info you'd need to look at: http://ottopress[DOT]com/2010/wordpress-3-0-multisite-domain-mapping-tutorial/

Cheers!

share|improve this answer
    
Thanks Paramdeo. I am basically asking how I can have wildcarded subdomains, map them to a category which in turn sets some kind of global variable, transient, option value or cookie so I am able to ensure a user is only getting results within their particular region (custom DB queries). –  DigitalSea Mar 7 '13 at 23:50

If mod_rewrite is available in your environment, that would probably be the way to go. To map a subdomain to a certain category in WordPress, a rewrite rule like this could work -- put this in a .htaccessfile in the subdomain's document root.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^brisbane\.example\.org$
RewriteRule ^/$ www\.example\.org/category/brisbane/ [L]

To adjust the look of an individual category -- e.g. adding a localized logo and text -- you can create a custom template such as category-brisbane.php in your theme.


Please Note: This will only redirect the subdomain's root to the category page. If you wish to make more than just the category archive accessible via the subdomain (single pages, search, front page, etc.), a WordPress multiuser installation might be more appropriate.

share|improve this answer
    
Would this approach combined with the use of session cookies yield the desired result you reckon? If you can make that subdomain code a wildcard filter that will get all subdomains (except maybe www) it would redirect to the homepage, then in my script I would check for this value and set a cookie that I could check using an init hook or something. Can you set environment variables in the .htaccess to store values that can be fetched from a PHP script? –  DigitalSea Mar 7 '13 at 6:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.