• 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 get quarter for future date using Carbon?

Xdebug can't connect back to Docker host

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Adding Multiple Custom Post Types in Wordpress

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Entity provider not working in security.yml php symfony3.4 ({"code":401,"message":"bad credentials"}.)

What is my SQL missing?

Appending data to an anchor tag

Laravel - How to properly generate unique slugs from article titles?

Display a product custom field only in WooCommerce Admin single orders

how to create html table in php

How to add automatically collapse/expand in content wordpress (single.php)?

Display a product custom field only in WooCommerce Admin single orders

Could not decode a text frame as UTF-8.

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

About Contact Privacy policy Terms and conditions