Hello Timo,
There are two constants available:
MULTPLE_DOMAIN_DOMAIN – the current domain the user is browsing
MULTPLE_DOMAIN_ORIGINAL_DOMAIN – the original domain, where your WP is installed
You can use those constants to write any logic in your theme. Something like this in your header.php:
<?php if (MULTPLE_DOMAIN_DOMAIN === 'mycoolblog.com') : ?>
<h1>Welcome to my cool blog</h1>
<?php endif; ?>
If you want to check if the user is visiting any page that’s not your original domain:
<?php if (MULTPLE_DOMAIN_DOMAIN !== MULTPLE_DOMAIN_ORIGINAL_DOMAIN) : ?>
<p>Thanks for visiting my other domain!</p>
<?php endif; ?>
Sure, these are dumb examples but I think you can get the idea from them.
You can also use those constants inside a filter or an action.
Hi Gustavo,
great – thanks for this example. This helped me and worked fine!
Best regards,
Timo
Hello Gustavo,
I have an additional question about this topic: Is it possible to output the MULTPLE_DOMAIN_DOMAIN-value in a shortcode (or something like a shortcode)?
I want to have a text-output with a dynamic naming of a domain in it.
Thanks for some help with this!
Best regards,
Timo
Hello,
I found a solution with the creation of a shortcode for this:
function domain_shortcode(){
return MULTPLE_DOMAIN_DOMAIN;
}
add_shortcode(‘domainShortcode’, ‘domain_shortcode’ );
Best regards,
Timo
Hey Timo,
Could you give me details on why you needed this? Maybe I can add it to the plugin codebase as a new feature. I wanted to know more to make it more flexible, if possible.
Cheers!
Hi Gustavo,
I just wanted to output the domain in a text dynamically, for example
“MULTPLE_DOMAIN_DOMAIN” is a service for xyz
Hope you understand what I mean ;-).
Best regards,
Timo
Timo,
The latest update (v 0.8.5) now has a built-in shortcode. It’s called “[multiple_domain]”.