My solution to multiple domains
-
I perused the postings in this section for days and came up with this solution to multiple domains with custom image headers for each. Comments and questions are encouraged.
My client is using a child theme of purple-pastels for multiple domains relating to tutoring in many communities in the San Francisco Bay Area. Her main domain is https://tutordoctorsanfrancisco.com and she has add-on domains such as https://tutoringinsausalito.com, https://tutoringinberkeley.com, etc. Each add-on domain has its own installation of WordPress 3.3.1 and they all share the same database and the same content. Using bits and pieces from other posts in this section, I came up with a solution to have a custom header image for each domain. Note, however, some of the domains do actually share the same header image.
The solution I chose was to modify wp-config.php for each domain to contain something like the following code:
define('WP_SITEURL', 'https://tutoringinsausalito.com'); define('WP_HOME', 'https://tutoringinsausalito.com'); define('CUSTOM_IMAGE_HEADER', 'https://tutoringinsausalito.com/wp-content/uploads/header4.png');
Then I modified functions.php in the purple-pastels theme to look for CUSTOM_IMAGE_HEADER and use it if it is present:
if (defined('CUSTOM_IMAGE_HEADER')) echo '#headimg {background-image:url("' . CUSTOM_IMAGE_HEADER . '");}'; else if( get_header_image() != '' ) echo '#headimg {background-image:url(' . get_header_image() . ');}'; else echo '#headimg {background-image:none;}';
I probably should check for the existence of the image header, but I got lazy.
The custom image header defined in wp-config.php gets displayed properly and because of the setting of WP_SITEURL and WP_HOME, the user stays on the domain they have chosen, for example, https://tutoringinoakland.com.
I am an experienced software engineer with decades of experience and I have been working with WordPress for about six months.
I would appreciate comments and insights about the approach I have taken to solve my client’s desires. Please let me know what you think! I am especially interested in how closely this follows what an experienced WordPress developer might have done. I had considered posting a question in this forum, but decided to get my feet wet.
Thanks,
[sig moderated as per the Forum Rules]
- The topic ‘My solution to multiple domains’ is closed to new replies.