1

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.

  • look a the start of this function, you can use the filter pre_get_document_title to generate the title when you are on a event page : core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/… – mmm Jun 25 '18 at 17:43
  • I can but can not make the title dynamic as you have to enter the additional headers inside the plugin config... causing duplicate titles again. In order to make this work placeholders are used in the dashboard as so: <title>#_EVENTNAME - #_STARTDATE</title>, which I can get to work using their example but as stated, it wipes out the rest of the sites ability to properly handle the title tag feature. – ben.kaminski Jun 25 '18 at 19:14
  • do you have the last version ? I just try the version 2.0.35 and on a event page I have the title "Traditional music session - website name" then there is a different title on every event page. – mmm Jun 25 '18 at 20:29
1

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"
  • Just to add an explanation of what was done differently here: All of the conditional formatting I put in place from the "EME Plugin" website, I went and undid. Removal of the forced <title> tag from header.php, and removed the function to disable the title tag support 'remove_action( 'wp_head', '_wp_render_title_tag', 1 );' Once I undid what the plugin author recommended, I added the solution my @mmm into my functions.php file, from there, updated the EME Event Headers in the dashboard... works like a charm. – ben.kaminski Jun 26 '18 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.