Home › Forums › Calendar Products › Events Calendar PRO › Month and Venue in the Title of individual event
- This topic has 16 replies, 2 voices, and was last updated 11 years, 8 months ago by
Casey.
-
AuthorPosts
-
June 25, 2014 at 11:35 pm #252036
Nick Ritar
ParticipantHi,
I’m trying to add the Month, Year and Venue (or Tag) to the <title> tag for individual events on my site.
This is because we run events with the same event title over and over again at many locations / venues and I’d like to have more information on search results and FB shares etc than just the event title.
I’ve installed the Yoast plugin and tried to use the variables mentioned in https://theeventscalendar.com/support/forums/topic/include-event-date-in-event-page-title/ without much luck.
I’ve also mucked around with filteres in function.php… but also have not really gotten anywhere.
Any tips on how i might achieve this.
Cheers
NickJune 26, 2014 at 11:23 am #253253Casey
ParticipantNick,
Thanks for getting in touch! Take a look at this snippet, which has many different scenarios for changing the page title. That, along with our docs should at least get you started in the right direction.Just let me know if you have further questions. Thanks! 🙂
-Casey-
June 26, 2014 at 1:59 pm #253528Nick Ritar
ParticipantHi Casey,
That’s great. Thanks.
Can you please give me a pointer on where I can find out how to use variables (such as EventStartDate or Tags) in the above snippet. Or perhaps a short example.
Thanks for your help 🙂
June 26, 2014 at 2:09 pm #253547Casey
ParticipantNick,
Take a look at the following functions in our documentation, as I think they’ll do what you need:Hopefully that gets you pointed in the right direction. Thanks! 🙂
-Casey-
June 26, 2014 at 4:26 pm #253829Nick Ritar
ParticipantHi Casey,
Getting close,It’s working for the tribe_is_photo pages really well, but not for tribe_is_event…… if i just use is_single it works, but of course on blog pages as well
// Tribe events: Manually set title for each event listing type
function filter_events_title ($title) {
if ( tribe_is_event() && is_single() ) { // single event
$title = ‘Nicks attempt to get this working | ‘;
}
elseif ( tribe_is_photo() && !is_tax() ) { // Photo View Page
$title = ‘Upcoming Courses | ‘;
}
elseif ( tribe_is_photo() && is_tax() ) { // Photo View Category Page
$title = tribe_meta_event_category_name() .’ Courses | ‘;
}
return $title;}
can you spot whats wrong?
June 26, 2014 at 5:01 pm #253890Nick Ritar
ParticipantNo matter what page i am on tribe_is_event() does not return 1
June 26, 2014 at 5:58 pm #254005Nick Ritar
ParticipantI ended up giving up on tribe_is_event() and ended up using !comments_open and is_single to work out if it is an single event.
All this is being called through functions.php (just to be clear).
I’m having trouble getting many of the tribe functions to give me the expected result, for example tribe_get_venue() and tribe_get_venue_link() do not return anything via functions.php, but do within tribe-events/single-event.php
tribe_get_start_date does work however
if( is_single() && !comments_open() ) { // Single Events
$title = $title.tribe_get_start_date( $post->ID, false, ‘F Y ‘ ).’ | ‘;
}June 27, 2014 at 12:27 am #254515Nick Ritar
Participantwhooops scratch that… tribe_get_start_date( $post->ID, false, ‘F Y ‘ ) returns today’s date… nothing to do with the event.
I’ve tried your snippet in functions.php with the 2013 theme…… and it behaved the same. That is to say that it worked fro a Photo View page, but not an individual event page.
So it’s not anything in our theme.
June 27, 2014 at 6:24 am #255051Casey
ParticipantNick,
Take a look at the is_single() documentation. You can do a specific check for a post type like this:
is_single( 'tribe_events' )
It’s also possible that you need to add a ‘global $post’ declaration to the top of your function, in order for the $post variable to have data in it.
Hopefully those suggestions get you on the right track. Good luck and thanks! 🙂
-Casey-
June 27, 2014 at 6:53 pm #256380Nick Ritar
ParticipantThanks for the tip about is_single(). I’ll check that out.
At the moment that is not my problem though.
I can’t get tribe_get_start_date( $post->ID, false, ‘F Y ‘ ) to return anything useful. It just gives me todayts month, not the month of the event.
Can you please take a look at my code below and see what i’m doing wrong.
Cheers
NickJune 30, 2014 at 5:38 am #261948Casey
ParticipantNick,
Try doing something like this instead: https://gist.github.com/ckpicker/d6cf7cbd1d2d6ea70aefThat seemed to do the trick for me locally. Good luck! 🙂
-Casey-
June 30, 2014 at 5:06 pm #262928Nick Ritar
ParticipantNiether tribe_is_event( $post ) or is_single( ‘tribe_events’ ) resolves to true, when I am viewing a single event on a page like http://staging01.laocoffee.com.au/course/gourmet-mushroom-cultivation-sept-2014-sydney/
I can get ( is_single() && !comments_open() ) to resolve true for this page, but obviously this is a hack.
Even when I do get ( is_single() && !comments_open() ) to resolve true, $title.tribe_get_start_date( $post->ID, false, ‘F Y ‘ ) resolves to todays Month and Year, not the events date a year.
Thanks for your help so far, but can you think of any reason why the tribe variables are not returning anything useful.
Cheers
NickJune 30, 2014 at 7:38 pm #263134Casey
ParticipantNick,
Have you tried testing for conflicts, while your function is active? It’s possible that a plugin, or your theme is hijacking the $post variable in the ‘wp_title’ filter.I was able to successfully test my code and saw the TITLE tag changed.
Hopefully that helps to point you in the right direction. Good luck and thanks! 🙂
-Casey-
July 11, 2014 at 1:21 pm #350377Nick Ritar
ParticipantI still can’t get it to work… even with the twenty thirteen theme…. nothing else activated and a clean cache.
I’ve had a few people working on this project… looks like we might have to reinstall the plugins…as i think someone may have broken something in your code.
Would you mind leaving this open while i test .
Cheers
NickJuly 11, 2014 at 1:45 pm #350581Casey
ParticipantNick,
That’s fine, just let me know if you’re able to sort this out. Thanks! 🙂-Casey-
-
AuthorPosts
- The topic ‘Month and Venue in the Title of individual event’ is closed to new replies.
