<?php 

if ( have_posts() ) {
            $default_text =  esc_html(apply_filters('kopa_blog_default_text', get_theme_mod('blog_default_text', '')));
            $before_text = esc_html(apply_filters('kopa_blog_before_text', get_theme_mod('blog_before_text', '')));
            $after_text = esc_html(apply_filters('kopa_blog_after_text', get_theme_mod('blog_after_text', '')));

            if ( is_home() ) {
                if ( get_option( 'page_for_posts' ) ) {
                    echo $before_text . '<span> ' . esc_html(get_the_title( get_option( 'page_for_posts' ) )) . '</span> ' .$after_text;
                } else {
                    echo $before_text . '<span> ' . esc_html($default_text) . ' </span> ' .$after_text;
                }
            }elseif(is_tag()){
                $term = get_term(get_queried_object_id(), 'post_tag');
                echo $before_text . '<span> ' . esc_html($term->name) . '</span> ' .$after_text;
            }elseif(is_category()){
                echo $before_text . '<span> ' . esc_html(get_the_category_by_ID(get_queried_object_id())) . ' </span> ' .$after_text;
            }elseif(is_tax('product_cat')){
                $queried_object = get_queried_object();
                echo $before_text . '<span> ' . esc_html($queried_object->name) . '</span> ' .$after_text;
            }elseif(is_tax('product_tag')){
                $queried_object = get_queried_object();
                echo $before_text . '<span> ' . esc_html($queried_object->name) . '</span> ' .$after_text;
            }elseif(is_single()){
                echo $before_text. '<span> ' . esc_attr(get_the_title()) . '</span> ' . $after_text;
            }elseif(is_page()){
                if(!is_front_page()){
                    echo $before_text. '<span> ' . esc_html(get_the_title(get_queried_object_id())) . '</span> ' . $after_text;
                }
            }elseif ( is_day() ) {
                printf( esc_attr__( 'Daily Archives: <span>%s</span>', 'garajez-lite' ), get_the_date() );
            } elseif ( is_month() ) {
                printf( esc_attr__( 'Monthly Archives: <span>%s</span>', 'garajez-lite' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'garajez-lite' ) ) );
            } elseif ( is_year() ) {
                printf( esc_attr__( 'Yearly Archives: <span>%s</span>', 'garajez-lite' ), get_the_date( _x( 'Y', 'yearly archives date format', 'garajez-lite' ) ) );
            }elseif (is_search()){
                 printf( esc_attr__( 'Search Results for: <span>%s</span>', 'garajez-lite' ), get_search_query() );
            }elseif (is_author()){
                $author_id = get_queried_object_id();
                echo esc_html__('Posts created by', 'garajez-lite') . '<span>'. esc_html(get_the_author_meta('display_name', $author_id)) .'</span>';
            }elseif (is_404()){
                echo esc_html__('<span>Error 404</span>', 'garajez-lite');
            }
        }