I’m trying to override Fancy Title created using The7 Theme.
The7 Titles are generate from this function:

function presscore_get_page_title() {
    $title = '';

    if ( is_page() || is_single() ) {
        $title = get_the_title();

    } else if ( is_search() ) {
        $title = sprintf( __( 'Search Results for: %s', 'the7mk2' ), '<span>' . get_search_query() . '</span>' );

    } else if ( is_archive() ) {

        if ( is_category() ) {
            $title = sprintf( __( 'Category Archives: %s', 'the7mk2' ), '<span>' . single_cat_title( '', false ) . '</span>' );

        } elseif ( is_tag() ) {
            $title = sprintf( __( 'Tag Archives: %s', 'the7mk2' ), '<span>' . single_tag_title( '', false ) . '</span>' );

        } elseif ( is_author() ) {
            the_post();
            $title = sprintf( __( 'Author Archives: %s', 'the7mk2' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' );
            rewind_posts();

        } elseif ( is_day() ) {
            $title = sprintf( __( 'Daily Archives: %s', 'the7mk2' ), '<span>' . get_the_date() . '</span>' );

        } elseif ( is_month() ) {
            $title = sprintf( __( 'Monthly Archives: %s', 'the7mk2' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );

        } elseif ( is_year() ) {
            $title = sprintf( __( 'Yearly Archives: %s', 'the7mk2' ), '<span>' . get_the_date( 'Y' ) . '</span>' );

        } else {
            $title = __( 'Archives:', 'the7mk2' );

        }

    } elseif ( is_404() ) {
        $title = __( 'Page not found', 'the7mk2' );

    } else {
        $title = __( 'Blog', 'the7mk2' );

    }

    return apply_filters( 'presscore_get_page_title', $title );
}

I have some dynamical pages create using a plugin that query a db and put results in a dynamically generated page: every page is generated on call, so not stored in the db.

Now all pages get title from default page where the shortcode is inserted.
I need to dynamically change the title depending on the the generated page.

I’ve tried to put this function, but it doesn’t affect anything:

function presscore_get_page_title() {
    $title = '';

    if ( is_page() || is_single() ) {
        $title = get_the_title();

    } else if ( is_search() ) {
        $title = sprintf( __( 'Search Results for: %s', 'the7mk2' ), '<span>' . get_search_query() . '</span>' );

    } else if ( is_archive() ) {

        if ( is_category() ) {
            $title = sprintf( __( 'Category Archives: %s', 'the7mk2' ), '<span>' . single_cat_title( '', false ) . '</span>' );

        } elseif ( is_tag() ) {
            $title = sprintf( __( 'Tag Archives: %s', 'the7mk2' ), '<span>' . single_tag_title( '', false ) . '</span>' );

        } elseif ( is_author() ) {
            the_post();
            $title = sprintf( __( 'Author Archives: %s', 'the7mk2' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' );
            rewind_posts();

        } elseif ( is_day() ) {
            $title = sprintf( __( 'Daily Archives: %s', 'the7mk2' ), '<span>' . get_the_date() . '</span>' );

        } elseif ( is_month() ) {
            $title = sprintf( __( 'Monthly Archives: %s', 'the7mk2' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );

        } elseif ( is_year() ) {
            $title = sprintf( __( 'Yearly Archives: %s', 'the7mk2' ), '<span>' . get_the_date( 'Y' ) . '</span>' );

        } else {
            $title = __( 'Archives:', 'the7mk2' );

        }

    } elseif ( is_404() ) {
        $title = __( 'Page not found', 'the7mk2' );

    } elseif(  is_page_template( 'accomodations.php' ) ){
    $title = __( 'Test', 'the7mk2' );
}   else {
        $title = __( 'Blog', 'the7mk2' );

    }

    return apply_filters( 'presscore_get_page_title', $title );
}

any suggestion please?

Read more here: Dynamically Override Fancy Title


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: