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.

closed as off-topic by Tom J Nowell Aug 3 '17 at 14:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

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!
}
  • Thank you, Jake. I appreciate you finding this. Saved me! – Stephen Sabatini Aug 3 '17 at 15:01

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