Question

I use the Events Made Easy plugin to handle events for a client. Recently while scanning my site for issues, I noticed that I'm getting blasted with duplicate title tags in the "events" pages as they all output the same "Events - Websitename" <title> and are not specific to the event. Not only is this causing duplicate title tags, but finding a way to make this work using <?php add_theme_support('title_tag'); ?> is very difficult. On the plugin site for Events Made Easy, they have posted a workaround that works, but it essentially ruins any SEO performed by YOAST that I am also using.

The Solution proposed on the plugin website is to add this to functions.php:

remove_action( 'wp_head', '_wp_render_title_tag', 1 );

Then add the following right before the closing </head> tag in header.php which ruins the "title_tag" support through WP I'm supposed to add the following:

<?php if (!eme_is_events_page()) { ?>
    <title><?php echo get_the_title().' | '.get_bloginfo( 'name' );?></title>
<?php }?>

While this solution works on the events pages specifically, it breaks the ability to use not only Yoast SEO but the title_tag support for my theme.

Essentially, this solution only works for the events pages and leaves your other pages subject to the generic title | bloginfo page titles leaving YOAST SEO unable to make changes to these tags. This, to me, essentially is reverting back to before the "title_tag" support was available and is a hacky work around.

I've been experimenting with some conditional PHP to solve the issue but it seems like I'm trying to re-invent the wheel.

<?php wp_head(); ?>
        <?php if (eme_is_events_page()) { ?>
            <title><?php echo get_the_title().' - '.get_bloginfo( 'name' );?></title>
        <?php } elseif (is_front_page()) { ?>
            <title><?php echo get_bloginfo(); ?></title>
        <?php } elseif(is_page()) { ?>
            <title><?php echo get_the_title().' - '.get_bloginfo( 'name' );?></title>
        <?php } ?>

But using my own method, I have to account for every possible page, custom page template, tag pages, etc. Seems a bit dated. I would love to get some input on this issue, I want to keep using the title tag support on my theme and don't want to revert back to actually placing a <title></title> in my header.php

For those not familiar with the Events Made Easy plugin, the plugin itself has a place for me to enter additional headers within the plugin config. This requires the use of their "placeholders" for me to make the title dynamic. Events Made Easy Settings

So, some more traditional methods may not work due to the plugin config itself.

Was it helpful?

Solution

I try this following code with Events Made Easy version 2.0.35.
It looks like you were near of the solution. you have found all bricks but you don't have succeed to assemble them.

Try this code to deactivate the automatic title if this is a event page and if the config of the title is set in the back-end :

add_action("wp_head", function () {


    if (eme_is_single_event_page()) {

        $extra_headers_format = get_option('eme_event_html_headers_format');

        if (!empty($extra_headers_format)) {
            remove_action( 'wp_head', '_wp_render_title_tag', 1 );
        }

    }


}, 0); // priority 0 to be launched before the call of "_wp_render_title_tag"
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top