• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to set dynamic `home` and `siteurl` in WordPress?

phpwordpresshook


PHP Snippet 1:

//presumes server is set up to deliver over https

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);

PHP Snippet 2:

require_once(ABSPATH . 'wp-settings.php');

PHP Snippet 3:

function replace_siteurl($val) {
    return 'http://'.$_SERVER['HTTP_HOST'];
}
add_filter('option_siteurl', 'replace_siteurl');
add_filter('option_home', 'replace_siteurl');

Related Snippets

Transfer data between JavaScript and PHP through JSON

Store / Website Column in Magento 2 Admin Grid - Custom Module

Getting values for an enum?

Stop caching for PHP 5.5.3 in MAMP

Normalize DateInterval in PHP

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Wordpress add responsive srcset header image to theme

Laravel print last executed SQL query with Query log

file_get_contents() without "Http" to access external URL [closed]

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

How to set a domain name with php artisan serve

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

Input and output values for php into the browser?

Filter WooCommerce products with post__in and additional meta queries

About Contact Privacy policy Terms and conditions