There may instance where you made a mistake in Settings General and changed the urls by mistake
There are times when you change Domain Names and move to new host and you have data with old domain name or you are transferring website from a ip address url test site like http://ip address/~cpanel_username to a domain name and you need to change on posts as well.
You login on your host cpanel and click on PhpMyAdmin icon. Some host you will need to enter the database user name and password to go to PhpMyAdmin
Once in PhpMyAdmin you will see a list of database if you have more than one click on the database you need to work on.
First thing you need to do is backup your database by using export feature in PhpMyAdmin and save it as a sql file on your computer.
If you need to change the urls that are in Settings General the video below will show you how to change urls click on database option.
Step below is if you are changing your domain name
If you have posts and images on your wordpress chances are that the posts has old urls then you can change them by clicking on post table and click SQL option tab at top and add this code in box, be sure enter olddomain and newdomain with your domain names
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
and press Go
Once you have changed the urls you will need log in admin panel and reset your permalinks by changing to default settings and save and check your pages and posts and if all is working fine switch back to custom structure and add /%postname%/ and save.
Once you done the changes you should have your wordpress back with the changes.
The videos below will show how to use
How To Reset Urls Using Functions.php File
How To Reset Urls Using Database