• 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 implement placeholder in a php file for moodle plugin?

Woocommerce redirect after add-to-cart error

How to change the app environment at run time?

how can I set a session variable in Drupal 8 and get it in a php script?

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

Transpose csv file data [duplicate]

Show Custom Data in Woocommerce Order Details Admin Area

how to make my own auto increment in php?

PHP DOTENV unable to load env vars

Warning: A non-numeric value encountered

Make certain characters of a word from string bold

send email using gmail-api and google-api-php-client

PHP SoapClient: set a namespace without prefix

how to upload binary image to sql server using php laravel

PHP each() function replacement

About Contact Privacy policy Terms and conditions