0

I'm using The Events Calendar by Tribe. What I'm looking for is a way to see if an event is featured without using the shortcode and rendering their markup. Is there a conditional available such as tribe_is_featured_event() or something along those lines? I have not been able to find anything online regarding this. As a last resort, I will make a call to the database although I'm not sure where this is stored.

1 Answer 1

1

I believe you would want to use this function (from the-events-calendar/src/Tribe/Featured_Events.php:45):

/**
 * Confirms if an event is featured.
 * @param int|WP_Post $event
 *
 * @return bool
 */
public function is_featured( $event = null ) {
    $event_id = Tribe__Main::post_id_helper( $event );

    if ( ! $event_id ) {
        return false;
    }

    return (bool) get_post_meta( $event_id, self::FEATURED_EVENT_KEY, true );
}

I've never used the plugin, but it seems like you would use it like this (giving it the $post object or the post id):

if( Tribe__Events__Featured_Events::is_featured( $post ) ) {
    // it's featured!
}
1
  • Thank you, Jake. I appreciate you finding this. Saved me! Commented Aug 3, 2017 at 15:01

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