Skip to content

Instantly share code, notes, and snippets.

@DKudleichuk
Created May 19, 2022 07:56
Show Gist options
  • Save DKudleichuk/35d49889887c6794197f677c7b8662b8 to your computer and use it in GitHub Desktop.
Save DKudleichuk/35d49889887c6794197f677c7b8662b8 to your computer and use it in GitHub Desktop.
Dynamic WP_HOME and WP_SITEURL
<?php
$protocol = (!empty( $_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'] . '/';
$home = $protocol . $domainName;
define( 'WP_HOME', $home );
define( 'WP_SITEURL', $home );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment