WordPress custom permalink and archive link for custom post type

You need to either go into Settings -> Permalinks and click Save

Or if you’re doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON’T set this in code that runs (like in init, or on every page load):

https://developer.wordpress.org/reference/functions/flush_rewrite_rules/

register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
register_activation_hook( __FILE__, 'wdocs_flush_rewrites' );


/**
 * Flush rewrite rules on activation
 */
function wpdocs_flush_rewrites() {
    // call your CPT registration function here (it should also be hooked into 'init')
    wpdocs_custom_post_types_registration();
    flush_rewrite_rules();
}

tech