1

Situation: We have a lot of pages, and a lot of people editing.

Is there a way to freeze child page URLs, so if a parent page's permalink is changed then the child page on the old URL doesn't 404?

An alternative approach would be to ensure all children have a redirect rule created when the parent permalink is changed. I am less keen on this, as we already end up with multiple redirects for the parent page while an editor changes the permalink multiple times (to fix spelling mistakes/because they're told to)

2 Answers 2

0

If your concern is about internal links, You should be using the get_permalink() function, and using proper nav menu objects in your menus, never custom URLs.

If you would like to do this in the content, refrain from using the hyperlinking feature in TinyMCE, and make a shortcode similar to:

[permalink id="1"]link text[/permalink]. Registering shortcodes is extremely straight forward.

Bottom line, always get permalinks from IDs.

If your concern is about external links, redirects are all that will help. If you have an extremely high performing page or post, this is worth it. if not, it's more headache than helpful.

301 Redirects / template_redirect hook

You can use 301 Redirects when you are changing a page's permalinks to ensure old URLs redirect. You can also add actions to the template_redirect hook, but good luck debugging when you happen to add a new page that has the same URL as an old redirected page ;)

If you really want to ensure the parent does not affect the child, consider removing the parent slug from nested URLs and forcing children to live at the same level (URL wise), parent or not. 2 pages cannot have the same slug regardless of ancestors, so this is perfectly safe to do. This can be done by filtering the WP rewrite rules.

-1

Adding too many redirection is not a good idea, you can use any plugin like Search & Replace to replace the url in database and if your page has SEO ranking then you can add 301 redirect in .htaccess to notify the Search Engines about the change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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