• 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

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

how to see if database exists with PDO [duplicate]

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

PHP using str_starts_with for array to exclude same as with wildcard

Add New Parameter to Existing URL using htaccess

Eloquent insert id with sequence next value

Can we define variables in `.tpl` files?

Limit WooCommerce products in cart only from one custom taxonomy

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

WordPress Security Standards want me to escape my html, but how to do it correctly?

Getting values for an enum?

Laravel query builder binding parameters more than once

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

Get WooCommerce product variation attribute terms in admin products general box

About Contact Privacy policy Terms and conditions