• 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

How to set a domain name with php artisan serve

PHP Imap , php 7.4.3 on mac osx catalina

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Message: Set sys_temp_dir in your php.ini after installed composer

Laravel Command Schedule Not Working Properly

How to access a var with "-" in PHP [duplicate]

PHP mail sending empty mails

Laravel Carbon throws error The format separator does not match

Increase value by 1 on button click

CodeIgniter force_download is not working

(Laravel) How to delete multiple models including optional relationships?

Store multiple fields in JSON column (Nova CMS)

Combine multiple columns into an array as one of the key in a results set

How to show selected value using javascript in laravel

image source not readable

About Contact Privacy policy Terms and conditions