0

I am in need of building child pages with the same URL as a post_type.

ie; my post_type is work

  • I can publish a Page at /work and it works.
  • My posts under /work/thing-1 work
  • A Page under /work/page does not work, as it’s looking for a post_type of page there.

How can I have the child pages work while the post_type exists with the same slug? If I change the slug to works everything works. But the client wants the post_type to have the same slug structure as the pages.

My post_type is:

        "name" => __( "Portfolios", "clients-child" ),
        "singular_name" => __( "Portfolio", "clients-child" ),
    ];

    $args = [
        "label" => __( "Portfolios", "clients-child" ),
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "publicly_queryable" => true,
        "show_ui" => true,
        "show_in_rest" => true,
        "rest_base" => "",
        "rest_controller_class" => "WP_REST_Posts_Controller",
        "has_archive" => false,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "delete_with_user" => false,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => [ "slug" => "work", "with_front" => false, "with_archive" => false ],
        "query_var" => true,
        "supports" => [ "title", "editor", "thumbnail" ],
    ];

    register_post_type( "portfolio", $args );
}

add_action( 'init', 'cptui_register_my_cpts_portfolio' );

0 Answers0