Use case is somewhat simple – here goes:
- Five people share a single wordpress install – not multi-user
- Each person blogs and puts their posts in a their own unique category
- Each person has their own domain name
- All domain names are pointed or parked to same WP install folder
-
Each person’s domain name only shows the posts from their category, i.e.
- http://blogger1.com would return category archive of Blogger1’s posts,
- http://blogger2.com would return category archive of Blogger2’s posts,
- etc.
- Google friendly indexing for each domain name
- Prefer rewrite solution rather than redirect but redirect is acceptable
- A”master” account would be able to post or edit any of the bloggers posts via the “main” domain login.
- Bonus – if this could be extended to custom post types
Environment
- One installation of latest version of WP (not multi-user)
- Pretty Permalinks
- Cpanel – to set up domain parking
- No subdomains
- Access to
.htaccess
- Access to
functions.php
Here’s two different solutions (editing the specifics for your use case):
Doing a Redirect:
1.) At the top of your
/wp-config.php
file add the following:2.) Then add this to your theme’s
functions.php
file:The above will do a 302 redirect to
http://blogger1.com/category/blogger1/
when a request is made of any URLhttp://blogger1.com
other than one that starts withhttp://blogger1.com/category/
(you made need to make some changes to support other URLs.)Doing a “Rewrite”:
What the above does not support is “rewrite” vs. a “redirect” solution. If you want to that it is a little more complicated. The following code will result in the category page being loaded in the root path for any domain that is mapped in your
is_yoursite_blogger_domain()
function. Of course youris_yoursite_blogger_domain()
function could be validating against existing categories but I don’t know the full criteria so I just hard coded it. You can copy this code into your function’stheme.php
file or put into a.php
file of a plugin you might be writing. Note that this code also requires the code in the/wp-config.php
file above:And here’s a screen shot to show the second example in action:
(source: mikeschinkel.com)
Another probably better way to approach this would be with a custom taxonomy instead of categories, or even better yet, map the domain to a user name instead. That way it’s less work on the authors and you don’t have to worry about maintaining the blogger list in code or in a separate taxonomy list.
As for you “bonus”, sorry but I don’t follow what you want there.
Create the domain alias(es)
Add this to your wp-config file:
Go to your theme and add something like this to load the main content (used this for a one pager):
change the categorie, page or post slug to the domain name min the toplevel domain, in this case a toplevel domain only with 4 characters. For example: .com .net .org if you want to use something like .nl .be or .de than you should change the 4 into a 3. If you wanna use both than you’ve to add conditions.
Note: This may only work for one page, but I’m only giving you the idea. You can expand the functionality of the code yourself if it’s necessary