How can I disable products or any archive pages in WordPress / WooCommerce?
Simply insert the code below into your functions.php theme file.
function my_disable_archives_function() { /* Conditional checks examples: is_category() is_tag() is_date() is_author() is_tax() is_search() ... */ // Return a 404 for all archive types, except the my_custom_post_type archive. $post_types = array('my_custom_post_type'); if ( (is_archive() && !is_post_type_archive( $post_types )) ) { global $wp_query; $wp_query->set_404(); } }