0

Is there a way to update all internal links (in pages, posts, cpt...) when a permalink is updated?

Eg: I have a page exemple.com/mypage, and this page is linked in other pages and posts. If for any reason I decide to update the permalink of mypage. All the internal links to this pages are not updated, and if my name is totally different to the previous one, I get 404 errors.

I'm thinking about two solutions:

  1. Using shortlink in the link selector, and convert the permalink only on page rendering (like typo3 act). And optionally keeping history of the previous permalinks to manage 301 redirections.
  2. On permalink update, search / replace all the concerned permalinks in the database. Optionally keeping history of the previous permalinks to manage 301 redirections.

Any one knows if wordpress can be set to act like this? Or if any plugin already exists to achieve this job?

Thanks

0

WordPress by default does not help to solve this - which has always bugged me. However, by using plugins there are ways to achieve it.

  1. What do you mean by shortlink? I think this is too much of an overhead for this "simple" problem. If you meant shortcode, these are going to disappear with Gutenberg

  2. There are very good plugins such as Better Search Replace, which will work in most cases. Though if you have two sites /about and you could by accident also change the second one (/aboutme -> /teamme). Do this with caution and only if you know what you're doing.

  3. 301 redirection won't change the "broken" link itself, but the site will keep working. Plugins like Redirection or YOAST premium allow you to this.

In the end, it all depends. If there are alot of links, you don't want to have any links that target wrong but get redirected right, go with option 2. Do this on a test instance and test for edge cases.

If this is a one time change of a single page and you don't want to change 100s of other sites (or can't), go with option 3.

  • 1. By shortlink i mean Short URL http://example.com/?p=1234 2. Search / Replace is not an option since the final user is not technician 3. 301 redirection is just an option to keep the old URL valid If no solution already exists, I'll wrap the hooks in a plugin – user2752173 Mar 22 '18 at 10:45
  • @user2752173 I've actually never worked with the ?p=.. links, might be an interesting attempt. But you'd need to change how links are set in the editor and how they are output – kero Mar 22 '18 at 10:48
  • Did you try wordpress.org/plugins/redirection ? "Posts and pages can be monitored for permalink changes, and redirections automatically created." Free alternative to Yoast redirection – Pabamato Mar 27 '18 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.