Support » Networking WordPress » My solution to multiple domains

  • Resolved sninad


    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 and she has add-on domains such as,, 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', '');
    define('WP_HOME', '');
    define('CUSTOM_IMAGE_HEADER', '');

    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,

    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.


    [sig moderated as per the Forum Rules]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    I’m relatively new to WP and not a programmer. Have basic knowledge of HTML and php.

    I’ve got a main domain and sub-domain

    Intially I took the MU plugin route, but since I want to modify the look of the sub domain, decided to try having separate instals of wp and separate databases. Trouble is that when try wp-login to the sub-domain, it rejects password and kicks me to wp-login of main domain.

    I tried your modification above, but no help.

    What would you recommend?

    Thanks in advance,

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    Make your own topic please 🙂

    If you’re using multiple installs, however, you’re not using Multisite. We would suggest using Multisite and then a domain mapping plugin.

    Excellent solution, @sninad! I only used the ‘SITE_URL’ and ‘SITE_HOME’ portions, but they worked like a charm.

    Designing a mobile theme to be used strictly on webkit mobile devices(so desktop users are redirected to the about site), but still needed to set up a mirror site to load as a demo on the ‘About this project/theme’ site, this worked perfectly!

    I came here looking for a solution to a slightly different problem, but I felt like replying to this one anyway.

    If I understand correctly, you want to have different header images on different domains using the same database (and therefore probably the same theme?)

    Why not just modify the header of the theme and use the php command $_SERVER[‘HTTP_HOST’] to get the name of the domain that is called? Than use that for an image name, like…

    echo “<img src='”.$image.”‘ />”;

    Then simply put images on the server called

    Or am I totally misunderstanding the problem/solution here, in which case; sorry! 🙂

    …or even shorter…

    echo “<img src='”.$_SERVER[‘HTTP_HOST’].”.jpg’ />”;

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘My solution to multiple domains’ is closed to new replies.