Home › Forums › Calendar Products › Events Calendar PRO › tribe_is_event() failing on events without categories
- This topic has 5 replies, 2 voices, and was last updated 8 years, 9 months ago by George.
-
AuthorPosts
-
June 29, 2015 at 8:16 am #973538Ken CharityParticipant
I have several categories set up, some without events associated to them.
if ( tribe_is_event() ) { if ( is_singular( 'tribe_events' ) ) { // we are on a single event page echo 'Events Calendar Single Event'; } elseif ( tribe_is_month() && !is_tax() ) { // Month View Page echo 'Events Calendar Month'; } elseif ( tribe_is_month() && is_tax() ) { // Month View Category Page echo 'Events Calendar Category'; } } elseif ( is_archive() ) { echo 'Archives'; }
On month category page with events I get ‘Events Calendar Category’ output, with no events I get ‘Archives’
If I remove the
tribe_is_event()
check and use it like this:if ( is_singular( 'tribe_events' ) ) { // we are on a single event page echo 'Events Calendar Single Event'; } elseif ( tribe_is_month() && !is_tax() ) { // Month View Page echo 'Events Calendar Month'; } elseif ( tribe_is_month() && is_tax() ) { // Month View Category Page echo 'Events Calendar Category'; } elseif ( is_archive() ) { echo 'Archives'; }
I get ‘Events Calendar Category’ output on the category month view with and with out events for that particular category as expected.
Why is checking if the page is an events page failing on categories without events tied to them?
June 29, 2015 at 8:28 am #973548GeorgeParticipantHey Ken,
tribe_is_event() only looks for whether a single item is of the Tribe Events post type or not, so it seems to me like something like this might work a little better for your needs here:
if ( tribe_is_event() ) { if ( is_singular( 'tribe_events' ) ) { // we are on a single event page echo 'Events Calendar Single Event'; } } elseif ( tribe_is_month() ) { if ( ! is_tax() ) { // Month View Page echo 'Events Calendar Month'; } else { // Month View Category Page echo 'Events Calendar Category'; } } elseif ( is_archive() ) { echo 'Archives'; }
What do you find when you try this?
June 29, 2015 at 8:37 am #973554Ken CharityParticipantAh ok thanks for clarifying that. That would be similar to the second code snippet I wrote minus the check. I assume that Venues and Organizers can also fall in that tribe_is_event() check as well?
I was really trying to use tribe_is_event() as a wrapper for all ECP related pages. Is there such a helper function that exists?
June 29, 2015 at 1:56 pm #973693GeorgeParticipantHi Ken,
There is not a wrapper for all ECP-related pages.
As for venues and organizers, tribe_is_event() will return false for those because those things are not events.
To check for those things, there are equivalents however. They are tribe_is_venue() and tribe_is_organizer().
I hope that helps!
Cheers,
GeorgeJune 29, 2015 at 9:29 pm #973767Ken CharityParticipantThanks for the info.
July 1, 2015 at 4:43 pm #974381GeorgeParticipantNo problem!
-
AuthorPosts
- The topic ‘tribe_is_event() failing on events without categories’ is closed to new replies.