Those look like curly apostrophes, not straight… try changing them to straight (all of them in your code) like this:
function add_custom_types_to_tax( $query ) {
if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );