How To Change Your WordPress URL

Sometimes we need to change our WordPress URL. Perhaps you’ve developed a totally new site or are working on revamping a current site on a local server or sub domain. When the site is finished, it needs to be moved to its domain. How do you change your WordPress URL once it’s moved?

guy using a computerI was needing to do this just recently for a client. I used BackupBuddy to migrate to a new host and used the temporary url from the hosting company because I wasn’t ready to change nameservers before the migration. It went well and the site was up and running. The IT guy didn’t want to change nameservers, he just changed the A record to point to the site’s IP address. Of course that didn’t do anything to change the URL. So I did some searching to figure out how to do this.

I found two articles right away – the first one I read was from SiteGround.   The other one was from the WordPress Codex.

They explained that WordPress relies on its URL settings to work correctly so you can’t just move your database and files without letting WordPress know what happened. The URL settings are located in the database of the website. Modifying databases can be tricksy and I didn’t really want to do that. So I was glad to see there is an “update_option” provided by WordPress that makes it very easy.

I Added Some Code To Functions.php

The functions.php file you need to do this in is located in the Theme folder for the website. Make sure you get it from your child theme folder, if you’re using a child theme (and you should be). It’s a good idea to have a current backup of your site before you go changing files in your WordPress installation! Another caution I took was to vet the sources I used to fix my problem. I can trust the WordPress Codex and I have a lot of respect for SiteGround too.

I added these lines to the functions.php file of my theme:


The WordPress codex gives this explanation for what the code does:

  • The “Site Address (URL)” setting is the address you want people to type in their browser to reach your WordPress blog.
  • The “WordPress Address (URL)” setting is the address where your WordPress core files reside.

Remove The Code When Finished

After saving the file, I went to type in the site URL and clicked on all the pages and everything was showing up correctly. Then I opened up the functions.php file and removed the two lines of code. Once the site has been accessed, then the database stores those settings and it doesn’t need to be modified after that.

Doing this also updated and changed my URLs in the Settings>General area of the WordPress dashboard.

WordPress dashboard settings

Can I change My WordPress URL from the Admin Dashboard?

I’m not an expert here and I’m deferring to an article from In Motion Hosting where they say you can do it, but not when moving your WordPress to a new site and not if you’re having issues – whatever this means!

A friend of mine did this with a site I built for her and it really messed up the site. It was years ago, I didn’t know as much as I do now and it really threw me for a loop! Here’s the link to this article if you want to use it. Needless to say, I don’t use this method anymore!

Closing Musings and Thoughts

Everyone is at a different stage in their WordPress learning. The adding a couple of lines to the functions.php file was not a big deal to me as I’ve modified this file and others in my WordPress installation in the past. The way I learn is to READ a lot, perhaps look at a video of how to do something and then try it on my own. Sometimes I mess up and sometimes things work out well – this is how I learn.

Usually, I try things out on my own site because if I’m going to break something, I want it to be my site and not a client’s site. I have a backup downloaded or sent to an off-site location in case something happens to my hosting or site just in case before I go tinkering.

In my 5 years of organizing the local OKC WordPress meetup, I think the question I get most was how do I learn WordPress. My response is to get your hands dirty and just start trying things!

Scroll to Top