• 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

Passing a boolean value from checkbox in Laravel form

how to sort by a custom appended relation to model

Display specific shipping method if woocommerce product has specific acf field value

How to submit the custom form data in database in WordPress without plugin using ajax?

Message: Set sys_temp_dir in your php.ini after installed composer

Saving Data from form to database using AngularJS and php

Smarty if isset

Class AppHttpControllersUserController Does Not Exist

Laravel set default language not working

Access denied for user 'homestead'@'localhost' (using password: YES)

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

LARAVEL: How to fetch id dynamically in a query builder?

How to read laravel_session cookies saved in cookie memory of browser in client side?

Attempt to read property "view" on null when sending password reset email

php mysql + create a friend request system

About Contact Privacy policy Terms and conditions