• Resolved Daniel

    (@ddumondgmailcom)


    Hello,

    The code provided in the support forums:

    $event_cats = get_the_terms($post->ID, 'tribe_events_cat');
    
    foreach ($event_cats as $category) {
    	echo '<p>' . $category->name . '</p>';
    	echo '<p>' . $category->description . '</p>';
    }

    Is generating the following notices:

    PHP Notice: Undefined variable: post in
    PHP Notice: Trying to get property ‘ID’ of non-object

    Would anyone know how to resolve this?

    • This topic was modified 4 years, 11 months ago by Daniel.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Santiago

    (@sjaure)

    Hi there @ddumondgmailcom ,

    Assuming you are trying this code in the right template: /plugins/the-events-calendar/src/views/list/single-event.php
    Could you try this instead?

    $event_id = get_the_ID();
    $event_cats = get_the_terms($event_id, ‘tribe_events_cat’);
    foreach ($event_cats as $category) {
    echo ‘<p>’ . $category->name . ‘</p>’;
    echo ‘<p>’ . $category->description . ‘</p>’;
    }

    Let me know how it goes
    Best
    Santiago

    Thread Starter Daniel

    (@ddumondgmailcom)

    Brilliant Santiago! That cured it, the errors are gone! ??

    Thank you so much for your help!!

    Cheers! ????

    Plugin Support Santiago

    (@sjaure)

    Hey,
    I’m happy to hear that it worked!

    I will go ahead and mark this thread as ‘resolved’.
    Please reach out if anything comes up, we’ll be happy to help.

    Cheers!
    Santiago

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Category Description in List view’ is closed to new replies.