How to remove parent slugs from child pages permalinks?
To remove parent slugs from child pages’ permalinks in WordPress and avoid the 404 error, you’ll need to modify your code and add some rewrite rules. First, modify your code to remove the parent slug from the child page’s permalink: function my_pages_permalink($link, $post) { if ($post->post_parent) { $parent = get_post($post->post_parent); $link = trailingslashit(home_url($parent->post_name)) . $post->post_name … Read more