Monday, February 13, 2023
HomeWordPress Developmentpermalinks - WordPress not remembering previous slugs for pages

permalinks – WordPress not remembering previous slugs for pages


WordPress retains monitor of put up slug change with wp_check_for_changed_slugs() perform. The previous slugs are saved in wp_postmeta desk with _wp_old_slug meta_key and later redirects to present URL with wp_old_slug_redirect() perform.

That is why even after altering a put up’s slug, you get redirected to the proper put up.

Nevertheless, WordPress does not do that by default with pages (or any hierarchical posts).

It is nonetheless attainable to alter this behaviour by hooking into post_updated motion and replicate wp_check_for_changed_slugs() perform for pages (or any hierarchical posts) after which implementing the redirect logic utilizing old_slug_redirect_url hook.

Nevertheless, this isn’t advisable.

The primary cause is: pages could have a number of ranges (hierarchical). For instance, a baby web page may be page_a/child-1 and one other youngster web page page_a/child-2 (there may be many extra, with a number of ranges).

Now, altering page_a slug impacts each child-1 and child-2 pages. So to implement this correctly, whereas visiting each child-1 and child-2, WordPress must test for first child-1 or child-2 slug change, after which page_a mum or dad slug change. This form of multi degree checks will decelerate WordPress for hierarchical posts or pages.

You will discover a comparable dialogue in WordPress.org help.

In case you nonetheless want this, it is higher to make use of a redirect plugin and manually add the redirect for pages with previous permalinks.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments