Get an event’s event-category ID in shortcode
-
Goal:
Display 1 of 2 lines of HTML depending on the event category. It is being displayed by a shortcode added to the Single Event Page area of the Formating section. The shortcode has a simple if/then statement based on the category’s ID (term ID).
Issue
I can’t figure out how to get the term ID from within the shortcode. Not sure if the issue is my understanding of Events Manager, WordPress, or PHP. All attempts have resulted in errors or no output.
The code (1 of many)
$termlist = get_the_terms( get_the_ID(), 'event-category' ); echo $termlist[0]->term_id;
That causes an error.
Am I approaching the problem wrong? Any input is appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get an event’s event-category ID in shortcode’ is closed to new replies.