• Resolved webteamap

    (@webteamapergy)


    Does anyone know how to create the same slug for multiple custom post types? I am trying to make products_inner and products post type start with the slug: products. This is what I tried. I got a 404 for products page but the products_inner page worked though.

    This is what I am adding also to achieve the hierarchy of pages. products slug; /%field_product_category%/%field_brand%/%postname%/

    products_inner slug: /%field_product_category%/%field_product_high_level%/%postname%/

    Functions.php

    add_filter( ‘register_post_type_args’, ‘wpse247328_register_post_type_args’, 10, 2 );
    function wpse247328_register_post_type_args( $args, $post_type ) {

    if ( ‘product_inner’ === $post_type ) {
    $args[‘rewrite’][‘slug’] = ‘products’;
    }

    return $args;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    To clarify, you have the actual slugs being different, but when it comes to permalinks, you want both to be queried for with just permalink slug of “products” ? Say https://mydomain.com/products/some-product/

    Thread Starter webteamap

    (@webteamapergy)

    Hello. No in the custom fields I set them all to have products as the rewrite_slug. I have images, can i email them to you? But when i try to view them the pages, i get 404. I want to to be a hierarchy.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Perhaps instead of setting up multiple post types and trying to tie them all together, instead just have 1 post type and set it to be hierarchical so that you still get that parent/child relationship going. Beyond that, I suspect whatever you’re trying to achieve will take a lot of query customization to make work, which is outside the scope of what CPTUI handles directly.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Same slug for multiple custom post types’ is closed to new replies.