<?php if (is_woocommerce_activated() && (is_shop() || is_product_category())) { ?>
<h1><?php woocommerce_page_title(); ?></h1>
<?php } elseif (is_tax()) { ?>
<h1><?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?></h1>
<?php } elseif (is_home()) { ?>
<h1><?php echo get_the_title($post_id);?></h1>
<?php } else { ?>
<h1><?php the_title();?></h1>
<?php } ?>