1
votes

I have two Custom Post type,

register_post_type( 'classes', 
    array(
        .
        .
        'rewrite'   => array( 'slug' => 'classes', 'with_front' => false )
    ) 
);

register_post_type( 'lessons', 
    array(
        .
        .
        'rewrite'   => array( 'slug' => 'chapters', 'with_front' => false )
    ) 
);

I have created a custom admin UI to manage (create/update/delete) this two post type, the lesson post type is design to be a child post type for classes post type. So everytime someone create a lesson, it requires a parent post from the list of post type classes.

Now I have a problem with the url structure,

the URL of the classes will be site.dev/classes/class-post-name

and the URL of the lesson will be site.dev/chapters/lesson-post-name this is also the URL I can i see on wp_posts table under guid column

How can I acheive a URL structure like below that will also be stored as guid? site.dev/classes/parent-post-post-name/chapters/lesson-post-name

1

1 Answers

0
votes

Parent Post From Another Post Type and a new URL structure will help in achieving the results. The lessons post type should be hierarchical and classes should be non-hierarchical. One thing is notable in the metabox that you don't need to save the metabox manually. WordPress itself checks for field name parent_id and saves it.