functions – Removing all Category pages with one exception

Question

I am using this code to remove all category pages, however I wish to retain a certain category with ID number 20. How may 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();
    }
}

0
JoaMika 4 weeks 2022-11-02T13:00:34-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse