Home › Forums › Calendar Products › Events Calendar PRO › Event Date in SEO Title
- This topic has 8 replies, 3 voices, and was last updated 9 years, 6 months ago by
Bradley Pirman.
-
AuthorPosts
-
October 5, 2016 at 10:55 am #1172841
Bradley Pirman
ParticipantHi there,
We have a site that is throwing Duplicate Title SEO errors (error 200) because the client has created the same event name over and over again. We’re using Yoast SEO and rewriting titles.
We thought about using the %%date%% variable in Yoast but it’s the post date. This will work but it’s far less than ideal. Is there a way to have the SEO meta title of events reflect the event date?
That way we could create a structure of <event name> – <event date>. This is our ideal solution to the SEO errors.
Thanks!
/BradleyOctober 6, 2016 at 9:08 am #1173232Nico
MemberHey Bradley,
Thanks for getting in touch with us! I’ll help you on this π
Try adding the snippet below to your theme’s (or child theme’s) functions.php file:
/* Tribe, add event date to Yoast Seo title */
function tribe_add_date_to_title( $title ) {if( !class_exists('Tribe__Events__Main') || !is_singular( Tribe__Events__Main::POSTYPE ) ) return $title;
// tribe_get_start_time docs https://theeventscalendar.com/function/tribe_get_start_time/
return $title . ' ' . tribe_get_start_time(null);
}add_filter('wpseo_title', 'tribe_add_date_to_title');
Please let me know if this works for you,
Best,
NicoOctober 17, 2016 at 4:44 pm #1178016Bradley Pirman
ParticipantThis reply is private.
October 17, 2016 at 4:48 pm #1178020Bradley Pirman
ParticipantThis reply is private.
October 17, 2016 at 5:30 pm #1178037Bradley Pirman
ParticipantI have the event start date and time working using the attached code, but now I’m also getting the following error when trying to save changes on a Yoast SEO Titles and Metas page:
“Warning: Cannot modify header information – headers already sent by (output started at /home/carrwine/public_html/_wp/wp-content/plugins/the-events-calendar-date-in-title/the-events-calendar-date-in-title.php:29) in /home/carrwine/public_html/_wp/wp-includes/pluggable.php on line 1167”/* Tribe, add event date to Yoast Seo title */ function tribe_add_date_to_title( $title ) { if( !class_exists('Tribe__Events__Main') || !is_singular( Tribe__Events__Main::POSTTYPE ) ) return $title; // tribe_get_start_time docs https://theeventscalendar.com/function/tribe_get_start_date/ return $title . ' ' . tribe_get_start_date( null, true, 'F j, Y, g:i a', null ); } add_filter('wpseo_title', 'tribe_add_date_to_title');October 18, 2016 at 2:31 pm #1178674Nico
MemberThanks for the follow-up Bradley π
Good work spotting the typo in POSTYPE, changing that to POSTTYPE seem to be the way to go. With that change the code is working as expected in my local site.
Can you please try to paste the code in a plain text editor and then move it to the plugin once again? Sometimes copying code directly from the forums can lead to these type of errors. I also tried to reproduce this in my local test site but was able to edit an events meta and title fields, so not sure about it.
In case this is still an issue after doing what I suggested above please send me a screenshot of the settings you are editing that bring up the error and which line from the code is plugins/the-events-calendar-date-in-title/the-events-calendar-date-in-title.php:29.
Best,
NicoOctober 24, 2016 at 4:16 pm #1182178Bradley Pirman
ParticipantLooks like this is working. The header issue is from a different Events Calendar plugin I created. I’ll post in a separate thread.
Thanks!October 25, 2016 at 7:21 am #1182418Nico
MemberGlad to hear Bradley π
Iβll go ahead and close out this thread, but if you need help with anything else please donβt hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
AuthorPosts
- The topic ‘Event Date in SEO Title’ is closed to new replies.
