Home › Forums › Calendar Products › Events Calendar PRO › Event category in preceding title in month view
- This topic has 14 replies, 2 voices, and was last updated 10 years, 8 months ago by
Brian.
-
AuthorPosts
-
September 1, 2015 at 8:47 am #1000922
Joseph
ParticipantHello, just purchase TEC Pro and already lost. I need to replicate our previous calendar which had the category preceding the title of the event in the month view. So for example, I have 3 categories Band, Orchestra, Choir…then in the month view on say any day, the event for that day would be listed as – Choir: name of event, or Orchestra: name of event.
I think I need to add something to loop-grid.php but am unsure.Thanks
September 2, 2015 at 6:28 am #1001189Brian
MemberHi,
Thanks for purchasing Pro. I can help out here. However, I am limited in support customizations so I might not be able to provide all the coding.
In Month view you are looking to add the Event Category before the title correct?
To do that you want to follow our themer’s guide:
https://theeventscalendar.com/knowledgebase/themers-guide/
To move and edit this file in your theme:
the-events-calendar\src\views\month\single-event.php
There you could add the Event Categories to the title using the get_the_terms():
https://codex.wordpress.org/Function_Reference/get_the_terms
This function should work on that template:
get_the_terms( $event_id, ‘tribe_events_cat’ );
And you could use the get_the_terms examples on that link to get what you are looking for.
If you get started and would like some help please post your snippet and I an try to troubleshoot it.
Thanks
September 2, 2015 at 7:32 am #1001262Joseph
ParticipantOk, thanks. It looks daunting, but I’ll give it a shot. So I copied the single-event.php out of the /the-events-calendar/src/views/month to my theme folder at /enfold/tribe-events/src/views/month. Just to do a test, I erased the
$day = tribe_events_get_current_month_day(); $event_id = "{$post->ID}-{$day['daynum']}"; $link = tribe_get_event_link( $post ); get_the_terms( $event_id, ‘tribe_events_cat’ ); $title = get_the_title( $post );and refreshed and it didn’t seem to make a difference. Am I way off base?
September 2, 2015 at 1:52 pm #1001436Brian
MemberHi,
Try this directory in your theme:
/enfold/tribe-events/views/monthI remove the src, sorry if that is not clear.
Let me know if that works.
Thanks
September 3, 2015 at 7:10 am #1001603Joseph
ParticipantBrian,
No, that didn’t seem to have any effect. I tried erasing parts of the single-event.php file and didn’t any difference in the month view. Please advise.
September 3, 2015 at 7:51 am #1001622Brian
MemberI would start at the beginning and make sure the theme is active, the file is in the directory, and the changes saved in the template.
Instead of removing things maybe just add a word to see if it shows up.
Do you have caching on your site? Did your browser cache it?
September 3, 2015 at 10:03 am #1001694Joseph
ParticipantIt’s actually a fresh install, nothing is cached and only Tribe plugins are activated. I even tried doing the Return to Month snippet (https://gist.github.com/theeventscalendar/003fbdf6ab408bf21b6d), which you can see the copied file (nav.php) in the screenshot and it doesn’t do anything.
Please advise. Thank you.
September 3, 2015 at 10:46 am #1001701Brian
MemberOh sorry my bad I told you the wrong directory.
This is correct:
/enfold/tribe-events/month
I forgot both the views and src should be removed and replaced with tribe-events instead.
September 4, 2015 at 6:26 am #1002054Joseph
ParticipantOk, that worked for the nav.php file! Can you tell me if I was on the right path with the categories in title snippet?
September 4, 2015 at 8:53 am #1002143Joseph
ParticipantSo, learning here, bear with me Brian. I got the single-event2.php setup with :
$day = tribe_events_get_current_month_day(); $event_id = "{$post->ID}-{$day['daynum']}"; $link = tribe_get_event_link( $post ); $title = get_the_title( $post ); $cat = get_the_terms( $event_id, ‘tribe_events_cat’ );Then in the loop at the bottom, shouldn’t it be as easy as <?php echo $cat ?? ? I get an error with unable to convert to string.
September 4, 2015 at 9:42 am #1002164Brian
MemberHi,
You are close.
However, the get_the_terms returns and object so that is why you get the convert to string error.
Try this instead:
echo $cat[0]->name . ' - ' . $titleSeptember 4, 2015 at 11:45 am #1002216Joseph
ParticipantThanks Brian, I see that now on the WP page. I’m getting a
Fatal error: Cannot use object of type WP_Error as array in /public_html/home/wp-content/themes/enfold/tribe-events/month/single-event.php on line 198
error now. Do I need to create an array to hold the list? Any examples if so?
September 4, 2015 at 12:31 pm #1002231Brian
MemberHi,
That is strange I did not get that error at all and used all the same coding as you.
I do have to reformat the quote marks around this function:
$cat = get_the_terms( $event_id, ‘tribe_events_cat’ );Maybe that might help what you are seeing.
The WordPress Function itself has an example how to use:
https://codex.wordpress.org/Function_Reference/get_the_terms
September 4, 2015 at 12:58 pm #1002253Joseph
ParticipantYes! That was it. I was using Sublime and it was adding funky single quotes. Switched to Coda and it worked. Thanks so much for your help, it’s slowly making sense.
September 4, 2015 at 1:08 pm #1002261Brian
MemberGreat glad it is working now and you learned a little bit too 🙂
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks
-
AuthorPosts
- The topic ‘Event category in preceding title in month view’ is closed to new replies.
