Home › Forums › Calendar Products › Events Calendar PRO › SEO with Custom Addition to Functions File
- This topic has 12 replies, 3 voices, and was last updated 12 years, 3 months ago by
Brook.
-
AuthorPosts
-
December 30, 2013 at 1:38 pm #84965
reshetramah
ParticipantI have added the appropriate php listed in some of the other forums regarding SEO titles when using the yoast seo plugin with modern tribe events. I was having a couple of errors and am not sure how best to address them. Below is the code I am using – for the titles, on the default page the title still shows up as “Upcoming Events >>”. The default page is the map page and the map page is also showing up as “Upcoming Events>>”. In addition the month view page title works and the individual event pages work but the list view and the photo view are not working properly. Below is the code I am using.
<?php
add_filter(‘wpseo_title’,’my_custom_titles’);
function my_custom_titles($title) {
if( tribe_is_month() && !is_tax() ) { // Month View Page
return ‘Events Calendar | Reshet Ramah’;
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
return ‘Events Calendar’ . ‘ » ‘ . single_term_title(”, false);
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
return ‘Upcoming Events | Reshet Ramah’;
} elseif( tribe_is_past() || tribe_is_upcoming() && !is_tax() ) { // List View Page
return ‘Events List | Reshet Ramah’;
} elseif( tribe_is_event() && is_single() ) { // Single Events
return get_the_title() . ‘ | Reshet Ramah’;
} elseif( tribe_is_day() ) { // Single Event Days
return ‘Events on: ‘ . date(‘F j, Y’, strtotime($wp_query->query_vars[‘eventDate’]));
} elseif( tribe_is_venue() ) { // Single Venues
return get_the_title() . ‘ | Reshet Ramah Events’;
} elseif( tribe_is_map() && !is_tax() ) { // Map View Page
return ‘Events by Location | Reshet Ramah’;
} elseif( tribe_is_map() && is_tax() ) { // Map View Category Page
return ‘Location Event Categories | Reshet Ramah’;
} elseif( tribe_is_photo() && !is_tax() ) { // Photo View Page
return ‘Events Photo View | Reshet Ramah’;
} elseif( tribe_is_photo() && is_tax() ) { // Photo View Category Page
return ‘Events Categories | Reshet Ramah’;
} else {
return $title;
}
}
?>January 5, 2014 at 10:07 am #87039Brook
ParticipantHowdy reshetramah,
I believe that code was intended to work with our 2.x plugin, in which case it would have some issues. To remedy this I think some theme over-rides for those views will work wonders.
Before making any theme changes you will want to familiarize yourself with our themer’s guide. Once there, you will want to over-ride the three views you mentioned and add your custom content after or instead of the regular header. For instance, in \events-calendar-pro\views\pro\photo\content.php you will see some code like this:
<?php echo tribe_get_events_title(); ?>
That is the page title for the photo view. Just add | Reshet Ramah directly after it, but before the closing </h2>.Please let us know if this solution works for you. Thanks!
– Brook
January 6, 2014 at 6:44 am #87330reshetramah
ParticipantIf I am correct this would add that line of text to the h2 on the page – not the title tag. I would like to alter the title tags.
January 6, 2014 at 10:02 am #87420Brook
ParticipantOh that is my mistake. Well one thing that sticks out to me about your code is that the order of elseifs is wrong. Technically the map view is also an events list and list of upcoming events, so it meets the conditions for those and would never reach the bottom where you have set the map specific title. The following order should correct that problem: http://pastebin.com/WyYZcfRM
Do you mind if I ask where you found that code? I was not able to find it in any of our documentation. But, if it is from one of our official snippets I would like to correct it.
Please let me know if that fixes it. Thanks!
– Brook
January 6, 2014 at 10:59 am #87461reshetramah
ParticipantThat makes sense. This code definitely registered better – I guess it wasn’t clear that the map view is also an events list and list of upcoming events. One thing that is acting funny is the map view option (also set to default view). When I land on the event page it registers the title tag but then defaults back to “”Upcoming Events>>”. It also does this if I specifically click on the map view from the list of dropdowns. The other thing that does not register is the date query. All event dates are being read as January 1, 1970. Here is the final code I used http://pastebin.com/5hbHDs9r.
I found the original code here: https://theeventscalendar.com/support/forums/topic/yoast-ecl/
January 6, 2014 at 11:18 am #87473Brook
ParticipantRegarding the date issue, you would need to make $wp_query global in order to access it within a function: http://pastebin.com/zQhcKAFS
Thank you for the link and your final snippet. Please let us know if that works for you.
– Brook
January 7, 2014 at 9:26 am #87844Leah
MemberHi Laura,
I’ve gone ahead and re-opened this topic per your email request.
Cheers,
Leah
January 7, 2014 at 9:30 am #87847reshetramah
ParticipantOne thing that is acting funny is the map view option (also set to default view). When I land on the event page it registers the title tag but then defaults back to “”Upcoming Events>>”. It also does this if I specifically click on the map view from the list of dropdowns.
January 7, 2014 at 10:18 am #87865Brook
ParticipantI am unable to duplicate that issue. I am running this code. On my site Map View’s <title> stays as “Events by Location | Reshet..” regardless of whether Map view is the default, if I reselect View As Map, or if I click around and come back to the Map view. It never “defaults back”. Can you document all the steps required to reproduce this? Or perhaps open up access to your site and share a link on a page where this happens? Thanks!
– Brook
January 7, 2014 at 10:27 am #87867reshetramah
ParticipantThis reply is private.
January 7, 2014 at 11:58 am #87899Brook
ParticipantThanks for the login Laura!
This is evidently a “feature” of Yoast. It puts your custom title in the <title> tag of the blog so search engines will see it, then uses Javascript to override the the displayed title back to the default user friendly one. If you do not use Yoast’ filter (wpseo_title) and instead use the regular WordPress one (wp_title), you will see this issue stop. If it continues to give you issues though you will have to look to Yoast for assistance.
I hope the rest of the site goes well. I really like the look of it.
– Brook
January 7, 2014 at 2:12 pm #87954reshetramah
Participantthanks brook! i ended up using multiple functions – both for seo and for non seo. it is a weird way to think about it but, if you do not have the wpseo_title set then your site has no title tag when using the yoast plugin. alternatively if you do not have the wp_title then the default map page shows a weird title tag. below is the code i ended up using which is (thankfully) working well. i love the yoast seo plugin and wish that tribe either had better native seo features or could work well with the plugin.
January 7, 2014 at 2:34 pm #87960Brook
ParticipantThank you so much for sharing the solution. I am really glad to see you got it working.
I can see where you are coming from. Events are a potential goldmine for SEO purposes. If you have some specific feature recommendation in that regard please throw it up on our uservoice page: https://tribe.uservoice.com/
I marking the answer and closing this topic.
– Brook
-
AuthorPosts
- The topic ‘SEO with Custom Addition to Functions File’ is closed to new replies.
