Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_use_custom_parent_slugs($full_custom_slug, $post) {
- global $permalink_manager_uris;
- if(!empty($post->ancestors) && $post->ancestors && is_post_type_hierarchical($post->post_type)) {
- $full_slug = $post->post_name;
- foreach($post->ancestors as $parent) {
- $parent = get_post($parent);
- if($parent && $parent->post_name) {
- $custom_slug = (!empty($permalink_manager_uris[$parent->ID])) ? basename($permalink_manager_uris[$parent->ID]) : '';
- $full_slug = (!empty($custom_slug)) ? "{$custom_slug}/$full_slug" : "{$parent->post_name}/{$full_slug}";
- }
- }
- }
- return $full_slug;
- }
- add_filter('permalink_manager_filter_default_post_slug', 'pm_use_custom_parent_slugs', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement