I need to know how to check if the user is looking at an event or the list of events from the plugin The Events Calendar on my custom theme's page.php.

One solution I thought of was to grab the url. mysite.com/events shows the list of events, and mysite.com/event/theevent shows a specific event. I thought about grabbing the permalink using get_the_permalink() / get_permalink() and checking if it contains event/events, but that doesn't seem to be returning anything for me while on an events page.

Or if I could set the category (the actual wordpress category, not the calendar category) to something like "events" I could use has_category('events'), but I don't know how to do that..

Any suggestions?


I went snooping around in The Event Calendar's php files and found tribe_is_event() and I'm able to determine if the page is an event, but only after the_content() has been called. I need to know before that happens.

  • 1
    Are the events a custom post type? – Andy Macaulay-Brook Oct 13 '16 at 16:30
  • Sorry, I guess i forgot to mention im using The Events Calendar plugin. Edited. – bwoogie Oct 13 '16 at 16:33
  • Ah. Do they have support? – Andy Macaulay-Brook Oct 13 '16 at 16:40
  • They have a list of functions, but I haven't found anything useful yet, and when I think I have it's deprecated. theeventscalendar.com/functions – bwoogie Oct 13 '16 at 16:50

You can get the post id outside the loop with $wp_query and then feed it to tribe_is_event(). works a treat.

global $wp_query;
if (tribe_is_event($wp_query->post->ID)) {echo "yup"; } else {echo "nah"; }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.