a quick search shows another stackexchange topic on this, and it used this code to cleanup the permalink of parents/ancestors:
function wpse_101072_flatten_hierarchies( $post_link, $post ) {
if ( 'page' != $post->post_type )
return $post_link;
$uri = '';
foreach ( $post->ancestors as $parent ) {
$uri = get_post( $parent )->post_name . "https://wordpress.stackexchange.com/" . $uri;
}
return str_replace( $uri, '', $post_link );
}
add_filter( 'post_type_link', 'wpse_101072_flatten_hierarchies', 10, 2 );
You can find that discussion here: Removing parent slug from URL on custom post type
Related Posts:
- Why is “/page/2/” not working?
- How does WordPress handle permalinks?
- WordPress 4.4+ breaks Walker Extension
- Custom Post Type: Get most recent permalink
- Page permalink conflict with Date
- permastruct for custom post type not working in one of four cases
- If permalink is equal to current site url
- Is there a way to regenerate page permalinks without a plugin?
- How to Remove Slug From Database?
- How to use author id in post permalink
- Remove parent slug for child pages
- WordPress 403 issue when passing parameters in the URL
- Change the custom post type permalink
- Media items hogging pretty permalinks
- Make Category Base Appear in Posts Permalink (but not tags)
- Getting a 500 internal server error ONLY on wp-admin/options-permalink.php
- Image Attachment Url Rewrite
- How to replace “wp-content/blogs.dir” with “media” for attachment permalinks?
- After moving from subdirectory to home, home page does not display
- If the only permalink setting is %postname% what happens in the case of old duplicates?
- How to hyperlink both post thumnail image and post title text in wordpress?
- How to modify the slug for the default wp posts without affecting other posttypes?
- Permalinks okay some pages but 404 error on others
- Automatically append ID to at the end of specific URLs
- Force pretty permalinks?
- WordPress get permalink function
- WordPress Permalinks & Nginx Rewrite Rule Not Working
- Page and Category With Same Slug – Looking To Silo Website
- Override category permalink to match old non-WordPress links?
- filtering special chars from post slug
- How to change old permalink?
- Losing preview ability: W3 Total Cache + Post name permalinks
- Get the url of a page template without using the page slug and ID
- How to rewrite a URL to another rewritten URL without changing the address?
- Broken Link in WP Site?
- How to change “attachment_id” in attachment permarlink?
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- Custom permalinks in WordPress
- Permalink opens attachment instead of page
- How do I get thumbnail generator to recognize the_permalink tag?
- wordpress how to replace url /bar with foo/bar for custom post type
- Changing WordPress routing to load the same page for different URLs
- Custom post type clean shortlink
- Exclude single page from permalink rule
- the_content(); erroneously closing off previous opening before it
- Bulk append URL (add word to slug)
- Home page Pagination – Other pages do not redirect to home page template
- Image URL and size
- defining child page permalink
- WordPress switch servers
- Browsing to permalink prefix results in 404
- Shortcodes not working
- WordPress Posts forced to load as Uncategorized
- replicate url permalink after migrating to wordpress
- I need to change the attribute of the isPermaLink guid in the WordPress RSS feed – from false to true
- Shortlinks work only for logged in users
- Modify post slug before saving
- Changing permalink for blog posts, current structure www.website.com/blog-post, change to, www.website.com/blog/blog-post
- Does wordpress take care of slug collisions?
- Permalink refresh, the good, the bad, etc. What is best?
- WordPress permalink not working on subdomain
- Fatal Error when trying to load Permalinks page on WP admin [closed]
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Cannot publish posts or pages when I change permalink structure
- Add /blog prefix for all WordPress front end url
- Permalink structure has suddenly changed
- How to experiment with permalink structure on a select number of posts
- Remove Permalink of certain posts
- Bulk update set of URLs via SQL
- Custom permalink for one category
- How to find a page in admin based on it’s permalink
- rebuilding/ rewriting a url to make it SEO friendly
- Very strange behaviour related to htaccess and custom posts and custom posts substrings (BUG?)
- Permalink change during save of post
- Changed Permalinks settings, how do I redirect posts on Nginx?
- Choose permalink on a per-post basis?
- where is the media permalink info stored in database?
- How to put articles under a /blog directory?
- Category-dependent custom permalink
- Pretty permalinks (again)
- How can I get WordPress CPT archives and page templates to work with prettified permalink settings?
- Passing user defined variable into get_permalink
- WordPress Archives Cause Looping
- Is there a way to add slug to home_url on this function?
- Customized author slugs not working with get_author_posts_url method
- Custom WP permalink structure
- Custom rewrites for pages and categories
- region selection
- Redirecting From An Old Permalink Structure
- How to change my URL on intranet
- Include language variable in url
- Is it posible to translate a url prefix?
- Error: “Sorry, this content could not be embedded” when using the Embed block
- WordPress Permalinks 404 Not Found
- WordPress 6.1.1 UTF8 Slug Limit Increase
- 301 Redirect posts to newly added categories
- How to have category/subcategory/posttitle/ permalinks?
- WordPress not remembering old slugs for pages
- make a new structure tag that does some processing
- Website appears with wrong permalink in Google’s search