I transfer WordPress website from localhost to live but there some url and images url not changes, how can change URL permalink in WordPress database by sql query or any other method.
I use below sql query but anythings not happen please help me...
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';
Thanks in advance
Here is a link to an article from the official wordpress.org page, it covers most of the url changing topic.
It shows the several diverent ways how to do it and also the sql way via phpmyadmin. The raw sql is not shown, but there are several methodes.
In this Blog post a very simple way is described.
I copied the relevant sql statments from the blog post:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
This should change the Url's easy
Related
I use this commands to migrate in the old day, but with divi or elementor, some crash with migration, anyone use other way ? other idea ? It's due to Json ?
UPDATE wp_options
SET option_value = replace(option_value, 'http://www.old-site.com', 'https://www.new-site.com')
WHERE option_name = 'home'
OR option_name = 'siteurl';
UPDATE wp_posts
SET guid = REPLACE (guid, 'http://www.old-site.com', 'https://www.new-site');
UPDATE wp_posts
SET post_content = REPLACE (post_content, 'https://www.old-site.com', 'https://www.new-site.com');
UPDATE wp_postmeta
SET meta_value = REPLACE (meta_value, 'http://www.old-site.com','https://www.new-site.com');
Thanks
You shouldn't change the guid as that will cause RSS readers to think that all of the posts are now new unread posts.
You might be missing some stuff to replace. Typically when migrating to the new site you do the find and replace on everything in the database (except for the guid). There are some tools that can help you out with this. If you use wp-cli, you can use the wp search-replace command. Otherwise, this is a great tool. Both of these tools will automatically handle doing a proper search and replace inside of any serialized strings.
Also remember to clear out your cache.
I am moving a website from shared hosting to a VPS but I am unable to import the database correctly as I am getting a 500 error on my website. I will list the steps I have taken below, please could you check that I am not missing anything, thanks.
I set up the VPS on Digital Ocean with the one click WordPress install and I set up the WordPress install etc.
Uploaded the theme and plugins to the correct folders on the sftp.
Created a new database on the VPS using Sequel Pro and then imported the old database to it.
Accessed the new database through mysql on the terminal and ran the following commands;
UPDATE sw13_options SET option_value = replace(option_value, 'https://olddomain.co.uk', 'http://newdomainIP') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE sw13_posts SET guid = replace(guid, 'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_posts SET post_content = replace(post_content, 'https://olddomain.co.uk', 'http://newdomainIP');
UPDATE sw13_postmeta SET meta_value = replace(meta_value,'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_options SET option_value = replace(option_value, 'https://olddomain.co.uk', 'http://newdomainIP') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE sw13_posts SET guid = replace(guid, 'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_posts SET post_content = replace(post_content, 'https://olddomain.co.uk', 'http://newdomainIP');
UPDATE sw13_postmeta SET meta_value = replace(meta_value,'https://olddomain.co.uk','http://newdomainIP');
Opened the config.php file and updated the database name to the new one and changed the table prefix to sw13_ and defined the site url.
Have I made a mistake or have I not done something?
I am not a huge expert in MYSQL nor Regex (I guess I need to use some here), I would appreciate any help.
So my problem is that I would like to change some hardcoded URLs in Wordpress post contents to different ones.
Here is an example of a URL:
http://cdn1.domain.com/wp-content/uploads/2017/05/16211742/Screenshot_051117_101304_AM.jpg
Now, 'cdn1' can be cdn, cdn1 or cdn2. We might need to run 3 queries, but that is not a problem.
I would like to change all instances of this to:
//domain.com/wp-content/uploads/2017/05/16211742/Screenshot_051117_101304_AM.jpg
So basically remove the cdn (cdn, cdn1, cdn2) part, and remove the timestamp URL part before the filename.
The Wordpress database is something like this:
UPDATE wp_posts
SET post_content =
WHERE
Thank you very much!
First of all, take a database Backup for safety.
Then you can do this with SQL Command like this
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
OR you can do this with the plugin called: WP Migrate DB
There has a tutorial on the plugin page. check that.
Hope it will help you. :)
I tried to change the post slug for a specific post using this query:
UPDATE wp_posts SET post_name = replace(post_name, 'make-me-happy','make-me-happy-2')
it worked, but it wasn't redirected to the new slug as I did it through the wp-admin dashboard.
You also need to insert into wp_postmeta table your post's old slug besides of your query, if want to get autoredirect. Your query:
UPDATE wp_posts SET post_name = replace(post_name, 'make-me-happy','make-me-happy-2');
Query for getting autoredirect:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES (1, '_wp_old_slug', 'make-me-happy');
post_id is the id of post, which slug you changed. The meta_value is your post's old slug.
WordPress make redirects using function wp_old_slug_redirect which hooked to action template_redirect.
Try adding a 301 redirect line of code for the single post into your .htaccess file.
Add something like the following into your WordPress installations root folder .htaccess file:
RewriteEngine On
Redirect 301 /make-me-happy/ https://yoursite.com/make-me-happy-2/
I ran this sql command as was trying to put a slash after domain.com so image urls worked when moving a wordpress website between domains and now all the post_content fields are just urls?
like this
http://domain.com?page_id=7
Any ideas why this happened or any way to change it back?
UPDATE wp_posts SET post_content = replace(post_content, "domain.comwp-content", "domain.com/wp-content");