The Misconception
get_site_url()
retrieves the site_url
option from the database, as set under General Settings in the administrative backend / wp-admin.
If this is indeed
the exact same wordpress installation
it will always return the same thing, regardless of whether the location is reachable via one, two or five hundred domains.
You might want to check $_SERVER['HTTP_HOST']
instead.
if ( 'domain2.com' === $_SERVER['HTTP_HOST'] ) {
$themeId = "gold";
} else {
$themeId = "blue";
}
Real Voodoo
So far, your condition only works for the initial visit to your site.
Should you care for some real trickery and want the visitor to keep surfing your page under the initial domain: Check out this excellent answer by toscho.
Related Posts:
- How to export/import theme customizer settings?
- Site Title and Tagline in Theme Options Page
- reason of splitting theme files to multiple files
- Editor role cannot save custom theme options
- wp_customize_image_control default value
- Dynamic URL to reference custom PHP files
- Site Title and Tagline in Pagelines DMS Options Panel
- How to override .htaccess with new rules without ftp or edit it manual
- Concatenate site_url and string doesn’t work
- How can one utilize a variable as a callback function name for add_settings_field
- theme options echoing multiple times
- Theme Options: If There is No Input, Don’t Display?
- Displaying theme options in css
- max_input_vars: how many am I using?
- Putting PHP variables into javascript [duplicate]
- Choose To Display Post Views With An Options Panel
- Set WordPress Default Template
- Set the checkbox as checked by default at options page
- Customizer – Prefix Class Extension
- Adding subdomain to home_url for “add_menu_page”
- Theme Options Page – User Updates Logo
- Selectbox in admin panel function linking to CSS
- Using if/else statements with output from theme options
- WP Post-Thumbnail
- Error: options page not found
- WordPress theme options error
- WordPress Options Page Theory Question
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Warning: Illegal string offset on theme options page [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Link blogname and blogdescription to the Options Framework
- How to add drag and drop functionalities to a div inside option panel
- How to return site_url() without https://
- How set a custom URL for a new theme file in WP?
- Undefined index for default custom theme option
- PHP if have image display image, if else text
- Php file that doesn’t recognize wordpress functions
- Deactivate a plugin on wp version
- what does $options = get_option(‘test_theme’); do?
- Using theme options to change a border-radius value
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Illegal string offset in PHP function in via Theme Customizer
- Change CSS Variable value in Theme Customizer Live Preview
- How to find php variable of wordpress theme settings
- site_url() returns with additional backslashes
- wp_customize_image_control default value
- Removing all my hardcoded URLs with get_site_url()
- WordPress Setting page can not be saved by html radio
- Not able to call class in NHP framework
- check if .min.css stylesheet exists
- Category List in Theme Options Page
- How to change a specific character in a theme option value – replace a space with a plus sign
- Setting field not saving on front-end
- Select area and checkbox data is not saving?
- Options.php loop won’t show!
- How to add a .php file to WordPress
- When to use Exceptions vs Error Objects vs just plain false/null
- Woocommerce get selected shipping zone id for the current user
- Include files in functions.php
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Add to previous posts under post
- How to show order data by multiple ID?
- how to create and show sessions in word press?
- How to trash multiple post/product programmatically
- Loading jQuery in the footer after removing jQuery migrate?
- Sending jsPDF documents to the server
- Unit Test in WordPress
- “before delete post” action fire when the post is updated?
- WordPress excerpt not working
- Custom Text in WooCommerce Order Processing Email Based on Products
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Error when adding excerpt to the content through functions.php
- Fresh Install WP error – “The site is experiencing technical difficulties” [closed]
- Woocommerce : Can’t get product info in loop
- Echo possibly causing custom template formatting conflict
- How do I create my own .php file with a code part and echo it on different pages?
- Conditional using get_the_ID() not working [closed]
- HTML table attributes ignored
- How to use wordpress function wp_enqueue_script() in php?
- Create a package of products as one Item in woocommerce?
- Add a custom class to the body tag using custom fields
- how to edit a specific post slug using a php code?
- Display the video of a post_format Video
- Display multi-select box choices in a bullet list [closed]
- the_post(); prints out style text into my HTML?
- Calling code from another plugin to custom profile field
- Require()/Include() post template adding extra content
- Approval by Admin to confirm the change
- couldnt show short code atts in category
- Changing ALT-tag for logo in wordpress
- Help with preg_replace
- How to display last whole post on the homepage
- Resource 404 error on multisite subdirectory install
- Give permission to admin to see user’s page
- List of child pages fetch next results at link click
- How does add_action ‘comment_post’ work?
- reorder a WP_Query, using a dropdown
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- using a shortcode in a hyperlink
- Differences and dis/advanages between: Fast-CGI, CGI, Mod-PHP, SuPHP, PHP-FPM