I have created a custom post type for "Solutions" which will eventually replace all products that have been added in Woocommerce as I no longer have the need for a shopping cart.
So I need to copy the data from each product to a new 'solution' CPT.
I have the below code to set up the new post type:
function create_solution_post_type()
{
register_post_type('solution',
[
'labels' => [
'name' => __('Solutions'),
'singular_name' => __('Solution'),
],
'public' => true,
'has_archive' => true,
'rewrite' => [
'slug' => 'product',
],
]
);
register_taxonomy(
'solution-area',
'solution',
[
'labels' => [
'name' => __( 'Solution Areas' ),
'singular_name' => __( 'Solution Area' ),
],
'hierarchical' => true,
'show_admin_column' => true,
]
);
}
add_action('init', 'create_solution_post_type');
After resetting the permalinks, it works fine for the custom post type but whenever I go to view a woocommerce product page I get, "Oops! That page can’t be found."
I assume its because the slug for the product and solution is the same? Although I don't really understand why this would be a problem if the overall url is different eg. example.com/product/product-name in woocommommerce will become example.com/product/product-name-2 for the custom post type until I delete the products and remove woocommerce.
I need the CTP 'solution' and woocommerce products working in conjunction with the same 'products' slug. How can I achieve this?
Many thanks in advance for your help.