• I am trying to convert an existing hierarchy of around 300 pages to custom post types, in order to be able to manage them better.

    My problem is however, that once I convert them by using the plugin, after clicking “save”, WordPress adds a number at the end of the slug, as if they were duplicates. I tried refreshing the permalink structure as well.

    How can I convert hierarchical pages to hierarchical CPT?

    Here is the code for registering the custom post type:

    $args = array(
        'show_in_rest' => true,
        'public' => true, 
        'publicly_queryable'  => true,
        'show_ui'             => true,
        'menu_position'       => 4,
        'hierarchical'        => true,
        'has_archive'         => false,
        'query_var'           => 'holiday',
        'map_meta_cap'        => true,
        'rewrite' => array(
            'slug'       => 'holiday',
            'with_front' => true, 
            'pages'      => true,
            'feeds'      => true,
            'ep_mask'    => EP_PERMALINK
        ),
        'supports' => array(
            'title',
            'editor',
            'excerpt',
            'author',
            'thumbnail',
            'revisions',
            'page-attributes'
        )
    );
    
    register_post_type(
        'holiday',
        $args
    );

    The page I need help with: [log in to see the link]

  • The topic ‘Converting hierarchical pages to hierarchical CPT’ is closed to new replies.