• 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

Require a class from another class - php

Laravel lang slug in url

PHP Array split string and Integers

Applying programmatically a coupon to an Order in WooCommerce3

Custom add to cart button URL for specific product in WooCommerce?

Is there a way to use Foundry Model for Authentification inside Functional Tests?

WooCommerce - unset "<product> removed notice…" on cart page

Xdebug in Laravel is not working with VSCode

yii2 and mssql insert varbinary into model

Add bold text and line break into Laravel Notification Email

Laravel Collections. Is there some kind of assertStructure method?

Dropzone: Submit both form data and dropzone at once

Natural ORDER in Laravel Eloquent ORM

Pagekite error: FAIL: localhost:8080 is down

The "client_reference_id" argument is not passed

About Contact Privacy policy Terms and conditions