Custom posts don’t work

After custom post type registration, that is register_post_type() , try adding function flash_rewrite_rules();

This will automatically flush all rewrite rules so you won’t need to go to permalink settings each time.

See this page: https://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation

Example:

add_action( 'init', 'my_cpt_init' );
function my_cpt_init() {
    register_post_type( ... );
    flush_rewrite_rules();
}

As it’s said in the docs, it’s better to do that on plugin activation.