I\'ve completely re-written this question as it got a bit long, and I was worried people skipped it without reading it completely.
I have a custom post type (procedu
It seems like you've over complicated your problem a little. Would it work if you did the following?
http://example.com/custompostname/%category%/%postname%/
. Otherwise I think add_permastruct()
is the function you're missing. I'm theorising this looking at the solution at https://wordpress.stackexchange.com/a/253325/58884 for a similar problem. Some code like this:
function my_custom_rewrite() {
add_permastruct('procedure', '/%parent%/', false);
}
add_action('init', 'my_custom_rewrite');
rather than 'rewrite' => array( 'slug' => '%parent%', 'with_front' => false )
in the post type declaration. The 'slug' => '%parent%'
part of that declaration is an optional substitution for the name of the custom post type ($post_type
in the register_post_type() codex entry). So if you had 'rewrite' => array( 'slug' => 'wibblewobble', 'with_front' => true)
your url would change from http://example.com/procedure/%postname%/
to http://example.com/wibblewobble/%postname%/
. With 'with_front' => false
I don't think it does anything. When you've entered 'slug' => '%parent%'
I think WordPress is taking that as a string and not doing anything with it dynamically.
Also be sure to use flush_rewrite_rules();
. You can use it in the init
hooked function while testing and then move it to theme/plugin activation hooked function once it works.
Good luck!