Task – deleting all category pages with one exception

I am using this code to delete all category pages however I want to retain a certain category with id number 20. how can i do this please?

// Remove category archives
add_action('template_redirect', 'jltwp_adminify_remove_archives_category');
function jltwp_adminify_remove_archives_category()
{
    if (is_category()){
        $target = get_option('siteurl');
        $status="301";
        wp_redirect($target, 301);
        die();
    }
}

Leave a Comment