In addition to setting has_archive
you need to set rewrite
when you define the CPT. I replaced $archives
because your code snippet does not have it defined.
$rewrite = array('slug' => 'my-cpt-type', 'with_front' => false);
$download_args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable'=> true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => $rewrite,
'capability_type' => 'product',
'map_meta_cap' => true,
// Set has_archive to the prefix you want, so the archive is in the right place
'has_archive' => 'my-cpt-name/news',
// Also set rewrite to the prefix you want, which will affect individual posts.
'rewrite' => 'my-cpt-name/news',
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'author' ),
);
register_post_type( 'my-cpt-type', $download_args );
You will want to:
-
unregister_post_type(‘my-cpt-type’); to unregister the CPT, otherwise WP will not honor your changes. You will not lose any content when un-registering, it just clears the permalinks.
-
Re-register using the settings above, then visit your Settings > Permalinks page to flush rewrite rules. You should then have the structure you want – just be sure to clear your browser cache before you try hitting the new URLs.