Answer the question
In order to leave comments, you need to log in
Why doesn't it find child pages when using the custom url post type slug removal solution?
There is a parent (static) page "Services" and child pages: "Foundation" and "Roof".
The link to the "Foundation" page looks like this: mysite.ru/uslugi/fundament/
An arbitrary record type projects has been created for house projects.
To remove the projects slug from the home project url, I use the solution found on wp-kama:
function projects_post_type_rewrite() {
global $wp_rewrite;
$wp_rewrite->add_rewrite_tag("%projects%", '([^/]+)', "projects=");
$wp_rewrite->add_permastruct('projects', '%projects%' );
}
add_action( 'init', 'projects_post_type_rewrite');
function projects_rewrite_conflicts( $request ) {
if(!is_admin())
$request['post_type'] = array('projects', 'post', 'page');
return $request;
}
add_filter( 'request', 'projects_rewrite_conflicts' );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question