Update Rewrite Rules

If you install a theme or a plugin, it might be helpful to refresh the rewrite rules. If you want to do that, use one of the snippets below:ippets.

Plugin

If you use a plugin, add this snippet::

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

function wpkb_flush_rewrites() {
    // the registration of a CPT needs an additional 'init' hook
    myplugin_custom_post_types_registration();
    flush_rewrite_rules();
}

Theme

If you use a theme, add this snippet:

add_action( 'after_switch_theme', 'flush_rewrite_rules' );