Custom slug in url for CPT and taxonomy

When you register cpt and taxonomies, remove the rewrite argument completely (use the default) and then go to your dashboard, and from Settings > Permalinks set permalink structure to (Custom Structure) and type

/my-custom-slug/%postname%

Screenshots:


The setting:

enter image description here


The result:

enter image description here


save changes, and everything should be just like you want.