• 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

Check if my GET request has Header: Token

Edit product hook WooCommerce

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

How to disable widget block editor of WordPress?

backup files to google drive using PHP

Prestashop webservice API creating cart rules

How to loop sql table data inside a html table

How to make a foreign key not using primary key

Target Individual Form Instance/Counter Inside A PHP While Loop

How to show a popup modal in codeIgniter?

Losing session data after POST from third party website

java URL working on browser but not in client program

Change the alert text on add to cart action without selected variation in Woocommerce

Laravel PackageManifest.php: Undefined index: name

How to identify whether webp image is static or animated?

About Contact Privacy policy Terms and conditions