Support Forums

Yoast & ECP

  • Posts: 18 Topics: 9 Answers: 1
    | Permalink

    Hi Guys,
    We’re having a similar problem to a number of other posters on the forum with the page titles. At the moment we have no page title set at all for any of the events pages (we only use upcoming, past & calendar).

    I saw this and tried the same fix: https://theeventscalendar.com/support/forums/topic/editing-page-titles-when-using-wordpress-seo-plugin/

    It’s not working for me though. The filter is definitely being called as I can insert a die; statement and the script dies as expected. Here’s what I’m using:

    function eddytm_modify_past_events_title( $title, $separator ) {
    $new_title = ‘Upcoming Events';
    return $new_title;
    }
    add_filter(‘tribe_past_events_title’, ‘eddytm_modify_past_events_title’, 10, 3);

    function eddytm_modify_upcoming_events_title( $title, $separator ) {
    $new_title = ‘Some Events';
    return $new_title;
    }
    add_filter(‘tribe_upcoming_events_title’, ‘eddytm_modify_upcoming_events_title’, 10, 3);

    Any ideas?

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink

    Hi Jon,

    The first thing you should check is your code syntax. Your fancy single quotes above will not work – you need to use regular single quotes. I corrected this and popped the code in my functions.php file and it works for me. And just to confirm you are trying to change the HTML title tag titles and not the page title that appears on the page at the top of events correct?

    Please verify your code and confirm what you’re trying to change.

    Thanks,
    Jonah

    Posts: 18 Topics: 9 Answers: 1
    | Permalink

    HI Jonah,
    Thanks for getting back to me. The fancy quotes are only an issue because I’ve copied from my development environment into the comment reply box here. They’re fine in my source but to make sure we’re totally clear, I’ve put them here: http://pastebin.com/P66sGWLc

    And to confirm: yes, I’m trying to change the tag.

    Cheers.

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink

    Hi Jon,

    That code should work then. Maybe it’s your theme. Have you tried reverting to Twenty Eleven to see if the code works there?

    Thanks,
    Jonah

    Posts: 18 Topics: 9 Answers: 1
    | Permalink

    I hadn’t, but I’ve just tried it and it made no difference I’m afraid.

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink

    Hi Jon,

    Ok, can you send us a copy of your theme? Please email to pro [at] tri [dot] be and reference this thread and attention it to me. I’ll take a look and see what else I can find.

    Thanks,
    Jonah

    Posts: 18 Topics: 9 Answers: 1
    | Permalink

    All done. Thanks Jonah!

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink
    Correct Answer

    Hi Jon,

    I think I figured it out. If you are using WP SEO, you will not be able to use our filters to modify the titles, you need to use the WP SEO filter for ‘wpseo_title’ instead. Here is an example: https://gist.github.com/3710617_

    You can combine this with the conditional wrappers here to modify the titles for all the event plugin related pages: https://gist.github.com/2415009_

    Oh, and since your jagermaster themes header.php calls the wp_title plus the bloginfo(‘name’), you’ll want to remove the bloginfo part because ‘wpseo_title’ only filters wp_title.

    I hope that helps but let me know if you need anything else!

    Cheers,
    Jonah

    Posts: 18 Topics: 9 Answers: 1
    | Permalink

    Hey Jonah,

    That worked perfectly! Interestingly, and I assume it’s because of Yoast SEO, I still needed to call get_bloginfo(‘name’) in the filters, even though it’s still being called in header.php.

    Here’s the code I used in the end: https://gist.github.com/3712948_

    Note for anyone else reading, there’s lots of redundancy in this code as I haven’t fixed the page titles yet, but if you are only using a couple of different page titles then you can cut down the number of elseif conditions.

    The only thing I haven’t been able to do with the conditional wrappers you provided was past events. I’m not actually too worried about that in this case, but it’d be useful to understand for the future.

    Thanks for all your help!

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink

    Hey Jon,

    The code looks good and I’m glad you worked this out. To check for whether you are viewing past events or not you should be able to use:

    tribe_is_past();
    

    Cheers,
    Jonah

    Posts: 18 Topics: 9 Answers: 1
    | Permalink

    That worked perfectly. There is one issue with my code and that’s that the else statement sets ALL titles except for the ECP titles to be Events | Blogname. So I’ve removed that and it’s working fine.

    Thanks for all your help.

    Posts: 24 Topics: 6
    | Permalink

    here’s my take on TEC & WPSEO titles – I’ve added a custom taxonomy – tags – to tribe_events, so needed to separate that out to – http://pastebin.com/VVXMVn7M

    Posts: 4021 Topics: 4 Answers: 763
    | Permalink

    That’s awesome Ray! Thanks for the contribution!

    – Jonah

    Posts: 24 Topics: 6
    | Permalink

    well, it might have one or two small errors.. I’m still testing it – I also use a simple get event cat function ( http://pastebin.com/bzaSe984 ) which I was using to get the category – perhaps better to be using your own class – which I tried in the SEO title function…

    | Permalink

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

The topic ‘Yoast & ECP’ is closed to new replies.