Support

Home Forums Event Espresso Premium Events Archive page title

Events Archive page title

Posted: March 22, 2018 at 8:57 am

Viewing 8 reply threads


tsca

March 22, 2018 at 8:57 am

I see that others have had the same problem, but nothing I try will remove ‘Events Archive’ from my events listing page title. I have this code in my functions.php in my child theme:

add_filter(‘pre_get_document_title’, ‘ee_events_archive_titles’);

function ee_events_archive_titles() {
if ( is_post_type_archive( ‘espresso_events’ ) ) {
return ‘Trainings | The Social Change Agency’;
}
}

…but it does nothing.

The event listing page is using a template called ‘archive-espresso_events.php’

Thanks


Josh

  • Support Staff

March 22, 2018 at 9:07 am

Hi there,

The pre_get_document_title() actually filters the title tag, and that’s not the same thing as the title heading displaying on the top of the page.

Does your “archive-espresso_events.php” template have any code that outputs the “Events Archive” title heading?


tsca

March 22, 2018 at 9:47 am

Sorry – the title tag is what I meant – the title in the tab of the page thats used for SEO.

The template used is using the normal get_header() function as all the other WordPress pages. There’s nothing else within the template that has the word ‘archive’ apart from the name of the template file itself.


Josh

  • Support Staff

March 22, 2018 at 10:23 am

In that case, your code as-is should have an effect, but would be less prone to conflicting with other pages if it was changed to this:

add_filter('pre_get_document_title', 'ee_events_archive_titles');
function ee_events_archive_titles( $title ) {
    if ( is_post_type_archive( 'espresso_events' ) ) {
        $title = 'Trainings | The Social Change Agency';
    }
    return $title;
}


tsca

March 22, 2018 at 11:16 am

Still no luck. I guess I’ll need to leave it as it is.

Thank you anyway Josh


Tony

  • Support Staff

March 22, 2018 at 11:38 am

If you can send a copy of the theme to support[at]eventespresso.com we can take a quick look and see if anything stands out if you’d like?

The above should work so we’d need to look over the code to see what is happening.


Josh

  • Support Staff

March 22, 2018 at 11:43 am

It looks like Divi overrides the title with the same filter, if you look in the Divi theme, you’ll find this little gem:

add_filter( 'pre_get_document_title', 'elegant_titles_filter' );

When no priority is set, then WP defaults to priority 10. You can override their filter by setting a later priority (like 11) on your add_filter() call, e.g:

add_filter('pre_get_document_title', 'ee_events_archive_titles', 11 );
function ee_events_archive_titles( $title ) {
    if ( is_post_type_archive( 'espresso_events' ) ) {
        $title = 'Trainings | The Social Change Agency';
    }
    return $title;
}


tsca

March 22, 2018 at 3:17 pm

I didn’t understand a word of that, but it did the trick anyway! Had to go up to no.16.

Thanks so much 🙂


Josh

  • Support Staff

March 23, 2018 at 10:34 am

There’s a well-written explanation about filter hooks in this article:

https://docs.presscustomizr.com/article/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers

Viewing 8 reply threads

The support post ‘Events Archive page title’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso