Home › Forums › Calendar Products › Events Calendar PRO › is_main_event_page
- This topic has 5 replies, 2 voices, and was last updated 11 years, 10 months ago by
Casey.
-
AuthorPosts
-
June 5, 2014 at 6:48 am #206339
Lee
ParticipantIs there a function that will return true if a user is on the main event page? (i.e. site.com/events)
I was using the get_the_terms() function to retrieve the categories. Thanks
June 5, 2014 at 8:28 am #206548Casey
Participantleepettijohn,
Thanks for getting in touch! The tribe_is_in_main_loop() function should do exactly what you’re wanting to do here. Give that a shot and let me know if you have further questions. Thanks! 🙂-Casey-
June 5, 2014 at 7:26 pm #207902Lee
ParticipantWhere should this go? I have put it in a couple different places in the php code and every page I pull up (main, category, etc.) all respond that it is not in the main loop.
Here is the code I’m using
if (tribe_is_in_main_loop()){
echo ‘is in main loop’;
}
if (!tribe_is_in_main_loop()){
echo ‘is not in main loop’;
}June 6, 2014 at 6:08 am #208862Casey
ParticipantLee,
I’m so sorry, but this is my fault for not completely understanding your question. Your best bet would be to use something like tribe_is_view() and check for the particular view that you want to execute your code on. Something like this:
if ( tribe_is_view( 'upcoming' ) ){
echo 'is showing upcoming events';
} else {
echo 'is not showing upcoming events';
}
You should be able to use the following params with this function: month, day, week, single-event, upcoming, photo, and map.
Give that a try and also take a look at our documentation to see all of the ‘tribe_is_’ conditional functions that exist. Thanks! 🙂
-Casey-
June 6, 2014 at 9:16 am #209367Lee
ParticipantTook me a while but I used tribe_event_in_category()
I put this function in the list/single_event.php and asked if it was a certain category. Then I passed those variables to the list/loop.php and if the categories were different then I knew I was on the main event page.
Not a great solution but it works. =)
Like I said before, let me know if you incorporate a function that checks to see if the user is on the main page (site.com/events)
Cheers.
June 7, 2014 at 7:21 am #211348Casey
ParticipantLee,
Glad you were able to find a workaround. Since it looks like you’re all set, I’m going to mark this thread “Answered” and close it out, but feel free to start a new thread if you have further questions. Thanks! 🙂-Casey-
-
AuthorPosts
- The topic ‘is_main_event_page’ is closed to new replies.
