Remove Add to Calendar section from past events
-
I’m trying to find a solution to remove the Add to Calendar section from all past events. Because why would you want that there for previous events in the first place?
I’ve tried a bunch of different functions like the one below, but nothing works
/* Remove Add to Calendar from past events */
function hide_add_to_calendar_for_past_events() {
if ( ! function_exists( ‘tribe_get_end_date’ ) ) {
return; // Bail if The Events Calendar function is not available
}// Check if we are on a single event page
if ( tribe_is_event() && is_single() ) {
$event_id = get_the_ID();
$event_end_date = tribe_get_end_date( $event_id, false, 'Y-m-d H:i:s' );
// If the event has passed, add a CSS rule to hide the 'Add to Calendar' area
if ( current_time( 'Y-m-d H:i:s' ) > $event_end_date ) {
echo '<style>
.tribe-events-cal-links {
display: none;
}
</style>';
}
}
}
add_action( 'wp_head', 'hide_add_to_calendar_for_past_events' );The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Remove Add to Calendar section from past events’ is closed to new replies.