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!
- WordPress Customizer – How to save list of checkbox of pages?
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Only show image from custom field when present
- Cinema site, retrive the movies that actor play in
- How to include custom code on a page that’s set to act as homepage?
- retain querystring values when savincustom options in admin
- PHP if statement works in template files, but not header
- How Can I Edit the Registration Code?
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- Get categories names as an array to use it in theme settings
- Should i use the wordpress Options table or to create database table..?
- variable value disappears in a second loop
- Force Users To Relogin
- unknown issue in ‘header.php’ preventing theme from displaying fully
- Hide a div to subscribers(user role) in one page (is_page)
- Security updates to 3.3.2
- Where is this function’s callback getting its arguments from?
- How can I use a sliced image As banner? [closed]
- persist a variable set in header.php all the way down to footer.php
- Echo title attribute php
- Can a page contain php code?
- Last class on last headline?
- Unable to Find Space in Custom Function
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- Strip Paragraph Tag
- Unable to process php via shortcode
- working with term_relationships table
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Creating a mobile site by adding a new class to the body tag from functions.php
- WordPress plug-in for dynamic download link?
- Using WP functions such as the_title() in an included php file
- GET problem in WordPress
- WordPress gallery shortag
- Almost Done… Post Format Code
- wordpress admin plugin menu custom css
- Help with page nav?
- Show recent posts starting at a specific number archive
- Add title=”” to A PHP Code
- Get Page ID from Backend
- Help with WordPress function inside a shortcode
- Wpdb->insert() doesn’t insert new row after the last one
- WordPress plugin admin page – using WordPress function in linked php file
- HTML table attributes ignored