• 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 load Codeigniter 4 lang file into an array variable

WooCommerce Additional Information - if empty, hide

generate an Excel file using PHP

Laravel s3 upload file with metadata using pre-signed url

how to make my own auto increment in php?

How to make Canonicals with PHP

PHP - Store information with NO database

Explode not working properly with dash

PHP random string generator

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

How to Create WooCommerce Subscription Product via. REST API?

How to get AJAX to post on second page?

Changing font color in javascript

browsersync doesn't work with XAMPP

Hide specific products from unlogged users based in product category in WooCommerce

About Contact Privacy policy Terms and conditions