How to get events in the same category in the footer of a single page?

Home Forums Calendar Products Events Calendar PRO How to get events in the same category in the footer of a single page?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18844
    Martijn Meyer
    Participant

    In the footer of a single event page, I want to show six related events in the same category. However I have trouble getting the current category. Bit the same problem as this discussion: http://wordpress.org/support/topic/plugin-the-events-calendar-getting-event-category-fails

    Help!

    #18901
    Jonah
    Participant

    Hi Martijn,

    You should be able to use tax_query to query your event categories. What is the query you are working with so I can see what you’ve got so far? Please post your code to: http://pastebin.com / http://pastie.org or http://gist.github.com

    Cheers,
    Jonah

    #18912
    Martijn Meyer
    Participant

    Jonah,

    I have this now: http://pastebin.com/zPhrQjh7

    Problem is: line 2 doesn’t return the category of the current event. I tried to use tribe_meta_event_cats(‘ ‘,’ ‘), but that gave me extra stuff around it. I only need the current category.

    #18927
    Jonah
    Participant

    Hi Martijn,

    The problem is the event categories are not stored as meta data, they are taxonomies. So tribe_get_event_meta will not work in the code you’ve got. To get the current posts taxonomy terms (categories) you’ll need to use a native WordPress function like wp_get_object_terms() – http://codex.wordpress.org/Function_Reference/wp_get_object_terms

    That will return an array which you can then tap into like so: https://gist.github.com/3b29a226dc036de93039

    This will echo the first value in the array. This doesn’t account for instances where you will have more than one event category assigned to a post. That’s more complex and you’ll need to figure that out on your own.

    I hope that helps!

    #976765
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘How to get events in the same category in the footer of a single page?’ is closed to new replies.