0

I creating shopping cart, based on custom post types. And for this cart I have two related custom taxonomies.

  • I need to create shop.mysite.com instead of mysyte.com/shop only for this one custom post type.
  • I dont need multisite solution.
  • All posts of current post types will be opened as shop.mysite.com/some-post/.
  • Related custom taxonomies will be opened as shop.mysite.com/customtax/some-tax-value/.
  • Additionally also would like to redirect a few pages related to shop as shop.mysite.com/some-static-page/

Thank You for help!

2 Answers 2

1

While multisite would give you exactly what you wanted via domain mapping, you've opted to throw away this option in favour of the much more time consuming and harder method of manual htaccess rewrites etc.

The challenges you face include:

  1. Telling wordpress to rewrite the permalink URLs it outputs to shop.mysite.com but not for the whole site
  2. Redirecting users who arrive at mysite.com/shop/some-post
  3. handling the wordpress permalink infrastructure

How you would make it work without multisite:

  1. You would have to write out all your own permalinks, or add a hook so that get_permalink/the_permalink and the menus, etc all use the right domain
  2. You would need to setup a htaccess at shop.mysite.com so that it mapped on to the normal page. You would then need to check for the referrer at the normal page to redirect to the subdomain if its found.
  3. You would need to add the shop prefix in the rewrite when you register your custom post type
  4. When handling the subdomain, you will need to account for the /shop prefix else you will have shop.mysite/shop/some-post

OR

You could set up a second wordpress install on the shop subdomain with the same tables etc. This would be easier than the above, but would introduce certain other issues, and you would need two themes, hardcoded to filter out the content from the other counterpart.

How you would make it work with multisite:

  1. You would create a second site for the shop subdomain
  2. HTAccess rules would be added to forward any request to mysite.com/shop on to shop.mysite.com
  3. When you want to display shop items on the mainmysite.com domain, you would do the following:

http://codex.wordpress.org/Function_Reference/switch_to_blog

switch_to_blog($shopsiteID);
// display shop items
restore_current_blog();

As you can see doing it without multisite is considerably more work than doing it with multisite, since a lot of the work you would need to do has already been done to implement multisite.

I would recommend you attempt them in the following order:

  • multisite easy
  • Two installs hard ( cookie/upload hell )
  • One install hardest ( permalink hell )

The only solution that will get you what you want without massive kludges is the multisite option coupled with domain mapping. I estimate not using multisite will triple the number of hours and cost of this task with no guarantee of a satisfactory result at the end.

So yes, you do not need multisite, just like I don't need tires on my car, it is doable, but why make things hard for yourself. Multisite is going to be suggested a lot to you, because it is the easiest, simplest, fastest and safest means of doing it.

2
  • Thank you for help.. My problem - one design theme for all site. And i need to hard rewriting all design sections of the site with switch_to_blog() function for importing data to both directions ( site <===> shop ) ... And my shop using the same taxonomies and custom post types as the main site in admin section.. Nov 18, 2011 at 19:12
  • well you don't need all the content to be duplicated twice, just link between the two sites, and you don't need two duplicate the themes, just make the shop use a child theme if it needs to be different.
    – Tom J Nowell
    Nov 19, 2011 at 0:46
0

Add a page. point subdomain to that pages permalink (/examplepage) add file into the actual /examplepage folder that is created on your server when you point the subdomain to it with the following content:

/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/

/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/

$_GET['page_id']=4323;

define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require('../wp-blog-header.php');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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