Answer the question
In order to leave comments, you need to log in
How to change the url of one page to another via SQL query?
There was a page site.com.ua/kuhonnye-stoleshnicy it was replaced with a new one with a completely different address site.com.ua/stoleshnici-iskusstvennii-kamen
It is
necessary to replace all the links that are on the site from the old address to the new one. The easiest way to do this is through a database query. I'm not really familiar with SQL, so I'm asking for help from professionals. What request to register?
Site on Wordpress.
Answer the question
In order to leave comments, you need to log in
By default, WP urls for posts and pages are stored in the wp_posts table in the post_meta field. The value of this field must be unique.
The algorithm by which I would write the script:
1 created a data array with the old url and the new url.
2 Get all posts from the wp_posts table (you only need to take posts with a specific post_type value)
3 Would loop through all posts. I would look at each entry if there is a post_name in the array with the initial data in the cells with the old url. If it is, then update the value of this field to the new url.
Implementation will require global $wpdb, $wpdb->get_results(), $wpdb->update().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question