Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)

  1. Create custom action in function.php, which checks current page type (if it’s category or tag page).

    function hidden_term_name_action() {
        if( is_category() || is_tag() ){
            $term_id = get_queried_object_id();
            $term = get_term($term_id);
                echo sprintf('<h1 style="display:none;">%s</h1>', esc_attr($term->name));
    add_action('hidden_term_name', 'hidden_term_name_action');
  2. Paste this code in header.php, which fires this action and pastes term title inside hidden h1 tag.

    <?php do_action('hidden_term_name'); ?>

P.S. Not tested, but give it a try.