Event category in preceding title in month view

Home Forums Calendar Products Events Calendar PRO Event category in preceding title in month view

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1000922
    Joseph
    Participant

    Hello, 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

    #1001189
    Brian
    Member

    Hi,

    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

    #1001262
    Joseph
    Participant

    Ok, 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?

    #1001436
    Brian
    Member

    Hi,

    Try this directory in your theme:

    /enfold/tribe-events/views/month

    I remove the src, sorry if that is not clear.

    Let me know if that works.

    Thanks

    #1001603
    Joseph
    Participant

    Brian,

    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.

    #1001622
    Brian
    Member

    I 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?

    #1001694
    Joseph
    Participant

    It’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.

    http://prntscr.com/8c74xa

    Please advise. Thank you.

    #1001701
    Brian
    Member

    Oh 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.

    #1002054
    Joseph
    Participant

    Ok, that worked for the nav.php file! Can you tell me if I was on the right path with the categories in title snippet?

    #1002143
    Joseph
    Participant

    So, 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.

    #1002164
    Brian
    Member

    Hi,

    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 . ' - ' . $title

    #1002216
    Joseph
    Participant

    Thanks 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?

    #1002231
    Brian
    Member

    Hi,

    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

    #1002253
    Joseph
    Participant

    Yes! 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.

    #1002261
    Brian
    Member

    Great 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

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Event category in preceding title in month view’ is closed to new replies.