I have 2 custom post types: software
and hardware
. For SEO reasons I would like to have the permalinks of single software
and hardware
pages like:
https://domain.com/custom-post-name/
But as default WordPress adds post-type slug on it like:
https://domain.com/post-type-slug/custom-post-name/
I've removed the slug with following script that makes a replacement of the string. Now the single page is reachable with both urls described above and Google search console find 2 pages with the exact same content which is not good for SEO. Is it possible to change the complete structure of a permalink and get rid of custom post type slug?
register_post_type( 'hardware',
array (
'labels' => $labels,
'has_archive' => true,
'public' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail' ),
'taxonomies' => array( 'hardware-post_tag', 'hardware-category' ),
'exclude_from_search' => false,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'hardware' ),
)
);
register_post_type