Return category name with post in loop

Home Forums Calendar Products Events Calendar PRO Return category name with post in loop

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #32347
    Chris
    Participant

    I love this plugin. One thing I can’t figure out so far: I am getting my event data returned using global $post;
    $all_events = tribe_get_events(
    array(
    ‘eventDisplay’=>’upcoming’,
    ‘posts_per_page’=>10,
    ‘tax_query’=> array(
    array(
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘microsoft-excel-classes’
    )
    )
    )
    );

    foreach($all_events as $post) {
    setup_postdata($post);
    etc. and it is working great. But I would like to grab my category name and output it in my WordPress page. I have tried get_the_category() and the_category to no avail. Any help?

    #32351
    Barry
    Member

    Hi Chris, because our forum has a tendency to mangle code I’d like to be sure the code you posted above is accurate … so, can you paste a link to your code using a service like Pastebin or Gist? Thanks!

    #32358
    Chris
    Participant

    Hi Barry

    The link for pastebin is http://pastebin.com/2yK04ru2. The challenge I’m referring to in this ticket is on line 29 not working.

    Thanks
    Chris

    #32370
    Barry
    Member

    Ah, oh. So using the_category() function will return regular post categories, however The Events Calendar uses a custom taxonomy for this so you’ll need to use different functions to do what you want here.

    There are a few ways you might approach this but take a look at get_the_taxonomies() first of all or else you could do something like:

    $terms = get_the_term_list( get_the_ID(), $tribe_ecp->get_event_taxonomy() );

    #32371
    Barry
    Member

    * In my snippet above, you would need to populate $tribe_ecp first of all:

    $tribe_ecp = TribeEvents::instance();

    #32410
    Chris
    Participant

    Thanks Barry, that plugged my leak! I appreciate your help, especially on a weekend. You guys rock. You can close this ticket if you like.

    #32411
    Barry
    Member

    Cheer Chris 😀

    #978585
    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 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Return category name with post in loop’ is closed to new replies.