Skip to main content
33 votes

What's the difference between home_url() and site_url()

##TLDR: In a non-standard installation, you can place your WordPress files in a subdirectory of your website root. ...and still allow your visitors to visitors to access your WordPress "website&...
SherylHohman's user avatar
12 votes
Accepted

Switch from https back to http

You can try these: 1. make sure the values changed in database If you can't login to wp-admin > settings to confirm that, you can go to database, wp_options table and look for siteurl and home ...
Nabeel Khan's user avatar
11 votes

How do I change the Multisite URL?

There are 5 values need to change. From database. wp_options: options named “siteurl” and “home” wp_site wp_sitemeta: the option named “siteurl” wp_blogs: any entries in the “domains” column that ...
Дтдця's user avatar
6 votes
Accepted

Rewrite default post type

Use the field in the admin Settings > Permalinks page to set your permalink structure to /blog/%year%/%monthnum%/%postname%/. To prevent custom post types from inheriting the post permalink ...
Milo's user avatar
  • 78.5k
5 votes

Switching MultiSite installation from HTTP to HTTPS

I encountered the same issue: with WordPress multisite, there is no option or setting that defines if a site domain is HTTP or HTTPS. Even after replacing all occurrences in the database, a site ...
Manu's user avatar
  • 817
5 votes

When moving a WP site, why does wp-admin redirect to old site?

It is not a big problem. Your Database contains all previous links which cannot be automatically converted. There are two type of solutions for that: In wp-config.php add this code: define('WP_HOME',...
Aakash Bhagat's user avatar
5 votes

Ban SiteNames Multisite

You can filter domain_exists, a check that runs before a site is registered. If you return a positive integer, WordPress will not create that site. Despite its name, that filter lets you check the ...
fuxia's user avatar
  • 107k
5 votes

How to remove "http://" When Echoing URL?

Use this code to remove http:// and https:// $str = 'http://www.google.com'; $str = preg_replace('#^https?://#i', '', $str); echo $str;
Gopala krishnan's user avatar
4 votes

Modify site URL via functions.php of a theme

If instead of modifying functions.php you can modify wp-config.php, you can use the following: define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); Source: https://...
fergbrain's user avatar
  • 450
4 votes
Accepted

Does WordPress Strip Away the WWW from a Web Address

Wordpress will always redirect to the canonical URL of the content if you try to access a page not with its canonical url. If you installed wordpress without using a www then wordpress will assume ...
Mark Kaplun's user avatar
  • 23.4k
4 votes
Accepted

How to get rid of index.php?

This is a classical case. All you need to do is to use Rewrite Rules. With Apache, you can do it in .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ...
Scott's user avatar
  • 1,315
4 votes
Accepted

Wordpress suddenly changed all links to example.com/example.com/<Content>

Check your .htaccess file for the proper values. Here's what WP recommends; you may need to adjust for your configuration (from here; more examples that might help) https://codex.wordpress.org/...
Rick Hellewell's user avatar
4 votes

Google verification challenge with file location

Google wants to see that you have ownership of the domain, because on some sites, subscribers have the ability to upload to the media library. You'll need to upload the file using FTP/SFTP to the ...
Eric B.'s user avatar
  • 69
4 votes

How to remove "http://" When Echoing URL?

bloginfo echos its result, this is why your attempt to "get the value" and manipulate it results in nothing, as no value is actually being returned. If you want to get the relevant value you should ...
Mark Kaplun's user avatar
  • 23.4k
4 votes

Login redirect_to loop with reauth=1, cookie expiry set to 1 year in past

This was caused simply by the salts in wp-config.php being at the end of the file, after the call to wp-settings.php (they were inserted by an Ansible script) rather than above the line: /* That's ...
William Turrell's user avatar
4 votes

URL parsing - what is it?

Parsing means to analyze (a string or text) into logical syntactic components. Taking WordPress URLs into the question is something like this: // Get array of URL 'scheme', 'host', and 'path'. $...
rudtek's user avatar
  • 6,143
4 votes

Headless WordPress – Issue with plugin path

I understand the question and answer are from more than a year ago, but I just wanted to add some additional information in hopes it might be useful for future visitors of this Question. Recently, ...
Arman Shahinyan's user avatar
4 votes
Accepted

Get the URL of the page from which an ajax request has been launched within ajax callback

Ok got it, knew there must be some built-in WP solution to this. Simply call wp_get_referer() in your callback (for details, see this). At least it's working as I need it, let me know if there's any ...
DevelJoe's user avatar
  • 487
3 votes
Accepted

get url page template

if you're using a page template, then if you want to get the current page URL you could try to use this function: get_permalink(); or echo get_permalink(); if you want to print the result
Misha Rudrastyh's user avatar
3 votes

Wrong wp-admin URL

Eventually, I found the reason of this weird behaviour. It is caused by the JavaScript embedded in wp_admin_canonical_url() (https://developer.wordpress.org/reference/functions/wp_admin_canonical_url/...
Victor Wong's user avatar
3 votes

How to remove "http://" When Echoing URL?

You could use core PHP function parse_url(); for this. Example: $url = 'https://www.google.com/'; $url_data = parse_url( $url ); $url_data['host'] = explode( '.', $url_data['...
Michael Ecklund's user avatar
3 votes

Dynamic URL to reference custom PHP files

I'm not positive I understand the question, but if you're just trying to get the site URL, you can use the get_site_url() WP function. So, like this: $siteURL = get_site_url(); header("=Location: $...
Coltvant's user avatar
  • 187
3 votes

Remove / from www.example.com/

This isn't a WordPress thing, this is a browser/HTTP thing. Firefox may be showing the / as part of a setting, but example.com and example.com/ are the same URL. This Q on webmasters goes into more ...
Tom J Nowell's user avatar
  • 59.6k
3 votes
Accepted

How do I get the site url from a Block (within the block editor)

Perhaps this is because I've got WP set up as multisite. Yes, that's right, WordPress disables the siteurl (and also admin_email) settings on a Multisite — see register_initial_settings() for the ...
Sally CJ's user avatar
  • 39.3k
2 votes

When moving a WP site, why does wp-admin redirect to old site?

Just changing the site URL in the config will likely not update all of the internals to create a working dev site for you (unless the site is pretty bare-bones). You'll have problems with serialized ...
Sean Michaud's user avatar
2 votes

Wrong canonical link on wp-admin pages

wp-admin-canonical is broken, as it assumes how WordPress is installed. there was a plugin to fix it, but the plugin was removed from the plugin repository apparently. It is still on github and ...
Diego's user avatar
  • 21
2 votes

wp-config dynamic hostname in WP_HOME and WP_SITEURL

I've used a similar approach on many CMS projects throughout the years. It works really well for rapid development, but it does have issues. If you can trust that the web server (apache, nginx) are ...
incredimike's user avatar
2 votes
Accepted

Wordpress URL redirect

This is quite possible. First off, Making pagename/{customString} resolve as the page itself instead of 404, then, you're free to decide whether to keep the URI as is and serve the page content, or ...
Ismail's user avatar
  • 1,936
2 votes

Linking to pages/posts within the site

WordPress always uses the full URL when it inserts a link. There are a number of reasons for this, and they are all good reasons. You can add relative URLs yourself by simply typing your own links ...
Dane Morgan's user avatar
2 votes

Modify site URL via functions.php of a theme

This shouldn't be handled by your theme at all, but your local wp-config.php file. You can conditionally load local and unique wp-config definitions by wrapping in a conditional file_exists. Here's an ...
Matt Cromwell's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible