• 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

Generate random username based on full name php

add uri parameter to Route name in laravel

How to add a heading in between checkout fields of WooCommerce

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

How to debug in WooCommerce 3+

auth pages not getting css in laravel

Can I use a WooCommerce function without any WooCommerce page?

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Laravel query builder binding parameters more than once

Sort a multidimensional array by integer inside of a string value which is two levels down

Check if string contains a value in array [duplicate]

Shopify password update using Shopify API

Remove categories with all childs derived from parent category

TesseractOCR not working for Laravel

Remove product downloads section in woocommerce email notifications

About Contact Privacy policy Terms and conditions