Home › Forums › Calendar Products › Events Calendar PRO › Adding date info into SEO Meta Description
- This topic has 7 replies, 2 voices, and was last updated 8 years, 5 months ago by
Keith O Reilly.
-
AuthorPosts
-
November 21, 2017 at 3:35 am #1387871
Keith O Reilly
ParticipantHello, I was wondering if it is possible to add the date field into the Yoast SEO description text using some code edit?
I have managed to get it into the Title using this method
But I also need some date info in the description text to avoid duplicate descriptions.
Any ideas?
November 22, 2017 at 11:56 am #1389394Victor
MemberHi Keith!
Thanks for reaching out to us! Let me try to help you with this topic.
I think you could modify the snippet from that other tread to use the ‘wpseo_metadesc’ filter instead of ‘wpseo_title’ and modify the meta description to add the date in it.
I hope that helps. Let me know if you have any follow up questions.
Best,
VictorNovember 23, 2017 at 4:40 am #1389916Keith O Reilly
ParticipantHi Victor, Thanks for your advice,
I am already using that snippet to add the date into the Meta Title, so I would need to edit that code to add the date to the description also? I tried adding afer wpseo_title but it gave me an error. How do I add it so the date appears in the Meta Title and Meta description?
/* 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, 'M,j,Y', null ); } add_filter('wpseo_title', 'wpseo_metadesc', 'tribe_add_date_to_title');Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘wpseo_metadesc’ not found or invalid function name in /home2/gaybarce/public_html/gayberlin4u/wp-includes/class-wp-hook.php on line 298
November 23, 2017 at 4:54 am #1389918Keith O Reilly
ParticipantHello,
Sorry, I am not a programmer, but following the logic of the Title code, I changed it and added it as two separate lines, so I have the Title code and then added this for the Description code
/* Tribe, add event date to Yoast Seo title */ function tribe_add_date_to_metadesc( $metadesc ) { if( !class_exists('Tribe__Events__Main') || !is_singular( Tribe__Events__Main::POSTTYPE ) ) return $metadesc; // tribe_get_start_time docs https://theeventscalendar.com/function/tribe_get_start_date/ return $metadesc . ' ' . tribe_get_start_date( null, true, 'M,j,Y', null ); } add_filter('wpseo_metadesc', 'tribe_add_date_to_title');It is working, but I am not sure if this is the most efficient way of doing it?
November 24, 2017 at 7:09 am #1390650Victor
MemberHi Keith!
You are using the tribe_add_date_to_title function to pass into the wpseo_metadesc filter, but you are defining the tribe_add_date_to_metadesc function. It might be working because I guess you have previously declared the tribe_add_date_to_title function.
For both, the title and description you could use the following snippet:
/* 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, 'M,j,Y', null ); } add_filter('wpseo_title', 'tribe_add_date_to_title'); /* Tribe, add event date to Yoast Seo Description */ function tribe_add_date_to_metadesc( $metadesc ) { if( !class_exists('Tribe__Events__Main') || !is_singular( Tribe__Events__Main::POSTTYPE ) ) return $metadesc; // tribe_get_start_time docs https://theeventscalendar.com/function/tribe_get_start_date/ return $metadesc . ' ' . tribe_get_start_date( null, true, 'M,j,Y', null ); } add_filter('wpseo_metadesc', 'tribe_add_date_to_metadesc');Please give it a try and see if it works for you.
Best,
VictorNovember 24, 2017 at 7:44 am #1390683Keith O Reilly
ParticipantYes, that seems to be working. Thanks for your assistance.
November 24, 2017 at 8:01 am #1390711Victor
MemberGlad to be of help! 🙂
Thanks for following up to let me know it works for you.
I’ll close this now but feel free to open a new topic if anything comes up and we’ll be happy to help.
Best,
Victor -
AuthorPosts
- The topic ‘Adding date info into SEO Meta Description’ is closed to new replies.
