I have 2 custom post types:
hardware. For SEO reasons I would like to have the permalinks of single
hardware pages like:
But as default WordPress adds post-type slug on it like:
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' ), ) );