A client currently has a website set up with three distinct sub-sites (run off a single WordPress install), each with a slightly different theme (same layout, different colour scheme.
I currently have it set up so each sub-site is a page, with all of it’s pages as children. The header.php checks which page is the parent and includes the appropriate style.
The problem comes with pages that are identical throughout the site, which the client wishes to have accessible from each sub-site as a separate page.
For example the about page, should be accessible from /site1/about and /site2/about and use the theme for the site that has requested it, but display the same content on both.
I could just create the child pages, and set the rel=”canonical” to reference the original, but from a maintenance point of view, it would preferable to have a single page that the content is pulled from on each of the sub sites.
And so to the question, how do I get several URLs/pages to pull their content from a single source?
EDIT:
Here’s an example of the desired structure:
- www.example.com – Displays links to
the three main services, as well as
general information - www.example.com/about – Displays information about the client, styled to match www.example.com
- www.example.com/service1 – Displays navigation related to the specific service,
styled in it’s own individual colour,
alongside generic links (about,
contact) - www.example.com/service1/about – Displays the navigation and stylesheet for /service1, but using the content from www.example.com/about (and with a canonical link reference to www.example.com/about)
This is then repeated for /service2 and /service3.
I’m still struggling with the exact requirements but if I understand correctly I think you can do to accomplish your goals if you use the code I provide you below and then do the following:
Create a page for each of your services (which it sounds like you have already done):
/service1/
,/service2/
, etc.Create a “base” service page, with a URL of
/base-service/
; don’t worry, nobody will ever see this on the outside of the website.Assign
/base-service/
as the parent (or grandparent) page for all the “virtual shared” child pages you want replicated under each service.Create any service specific pages that you also might want to have and assign them to the proper page (i.e. “Service 2”, for example.)
Create a page template in your theme for your services called
page-service.php
and make sure each of your service pages uses that page template (this is needed so we can identify which of your pages are meant to be services).So here’s the code for a class that I called
Yoursite_SharedChildPages
which you can store in your theme’sfunctions.php
file, or in a.php
file of a plugin that you might be writing for your site:And here are some screenshots that can illustrate the steps mentioned above:
Let me know if this is not what you were looking for and/or if you run into something that needs to be addressed by this solution in addition to what I have coded. Good luck!