Showing the current event category id

Home Forums Calendar Products Events Calendar PRO Showing the current event category id

  • This topic has 7 replies, 2 voices, and was last updated 8 years ago by webinzicht.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1504877
    webinzicht
    Participant

    Hi there,

    I’m trying to show the ID (term_taxonomy_id) of the current event category. I did manage to show the current description with:

    echo term_description( $term_id, ” );

    but my attempt below throws an error.

    echo term_taxonomy_id( $term_id, ” );

    I found a way to show a bunch of the ID’s I need with a snippet from another helpdesk topic, but I’m not able to bend that around so it will only show the data of the current page:

    $event_cats = get_the_terms($post->ID, ‘tribe_events_cat’);

    foreach ($event_cats as $category) {
    echo ‘

    ‘ . $category->name . ‘

    ‘;
    echo ‘

    ‘ . $category->description . ‘

    ‘;
    echo ‘

    ‘ . $category->term_taxonomy_id . ‘

    ‘;
    }

    Could you point me in the right direction?
    Cheers!

    #1505435
    juanfra
    Keymaster

    Hello there,

    Thank you for reaching out! I hope you’re doing well.

    Where are you trying to put that code? I’d recommend, if you haven’t already, starting off by taking a look at our Themer’s Guide,

    Please have in mind that custom development tasks are outside of our stated scope of support. However, I’d love to help point you in the right direction.

    Best,

    Juan.

    #1505972
    webinzicht
    Participant

    Hi Juan,

    I’m testing this in [my-child-theme]/tribe-events/month/content.php right after:

    <div id=”tribe-events-content” class=”tribe-events-month”>

    I am guessing that this is the template part responsible for showing the event category page content and it is the spot where I would like to show more info on the current category. The first and third snippet work on that spot.

    Thanks for any directions you could give me.
    Cheers!

    #1506082
    juanfra
    Keymaster

    Hi,

    Thanks for the follow-up!

    That template is the content template for the month view of events. That template is also used for the response that is returned on month view ajax requests (the calendar itself).

    I guess the function you’re looking for is tribe_get_event_categories(). You can check more information about that function and the parameters you can use, by checking the documentation page of the function. That function displays the event categories. Perhaps it doesn’t adjust to your specific need, but in any case, you can check how it is that it goes through the categories by checking the function directly.

    I hope this helps! If you have any other questions please feel free to let me know and I’d be happy to help as best I can!

    Regards,

    Juan

    #1506101
    webinzicht
    Participant

    Hi Juan,

    I was seeing the text disappear in list view, so that’s why. Could you tell me what template part would be a better place for the description and such of the category so it will stay visible no matter what calendar view is chosen by the user? Or should I just paste the code to all views?

    I’ll try and figure out how to use the tribe_get_event_categories() function to my advantage further on in development. I did however just now stumble over the code below which seems to give me the ID of the current category for further use:

    echo get_queried_object_id();

    More on that via here: https://stackoverflow.com/questions/12289169/how-do-i-get-current-taxonomy-term-id-on-wordpress/12289287

    Hopefully this might be of use to someone. I was trying to connect to the infamous “Category and Taxonomy Meta Fields” plugin, which now works for me. On to the next challenge!

    Thanks!
    Mark

    #1506103
    juanfra
    Keymaster

    Hi Mark,

    Thanks for the follow-up.

    Well, the list view has its own templates that can be found here:

    • Main Template: /wp-content/plugins/the-events-calendar/src/views/list.php
    • Template Parts: /wp-content/plugins/the-events-calendar/src/views/list/

    You have a perfect example on how to customize the list view on the Themer’s guide here.

    The taxonomy is always linked to the post (event on the case of our plugin), so you may want to use the WordPress get_the_ID() function, when in context, to get the different taxonomies.

    Best,

    Juan.

    #1506119
    webinzicht
    Participant

    Hi Juan,

    Thanks for thinking ahead there. And thanks for the help on this.

    Cheers!
    Mark

    #1506515
    juanfra
    Keymaster

    Hi Mark,

    You’re welcome 🙂 I hope this helps! If you have any other questions please feel free to let me know and I’d be happy to help as best I can!

    Have a nice day,

    Juan

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Showing the current event category id’ is closed to new replies.