sajad torkamani

Suppose your permalink settings were configured to use the default Day and name option so that you now have many post links with permalinks that look like https://sajadtorkamani.com/2022/03/sample-post. You might be referencing these links across your site.

Now, you want to use the Post name permalink setting instead so that your future permalinks take the form https://sajadtorkamani/sample-post. Notice the absence of the post date.

You can run a MySQL regex replace against your database. Something like this:

UPDATE
	wp_posts
SET
	post_content = REGEXP_REPLACE(post_content, '(https:\/\/sajadtorkamani\.com)\/\[0-9]+\/[0-9]+\/[0-9]+\/', '$1/')
WHERE
	id = 112;

It’s a good idea to first test your SQL query against a single post to ensure it works as intended. Be sure to check out this post for more tips on how to perform a regex replace safely.

Tagged: WordPress