Same slug for multiple custom post types
-
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;
}
The topic ‘Same slug for multiple custom post types’ is closed to new replies.