Skip to content

Instantly share code, notes, and snippets.

@cliffordp cliffordp/functions.php
Last active Jan 10, 2019

Embed
What would you like to do?
The Events Calendar: Remove the month, day, and datetime separator from an event's start time display.
<?php
/**
* The Events Calendar: Remove the month, day, and datetime separator from an event's start time display.
*
* Example:
* Before: <span class="tribe-event-date-start">January 31 @ 10:30 pm</span> - <span ...
* After: <span class="tribe-event-date-start">10:30 pm</span> - <span ...
* DOES NOT APPLY WHEN USING WordPress 5's BLOCK EDITOR. For block editor, just use this CSS:
* .tribe-events-schedule__datetime > .tribe-events-schedule__date--start,
* .tribe-events-schedule__datetime > .tribe-events-schedule__separator--date {
* display: none;
* }
*
* @link https://gist.github.com/cliffordp/94012b1623319b20c93b04aa050ce917 This snippet.
*
* @see tribe_events_event_schedule_details()
*
* @param string $inner
* @param int $event_id
*
* @return string
*/
function cliff_tribe_remove_day_from_start( $inner, $event_id ) {
$start = '<span class="tribe-event-date-start">';
// If doesn't start as expected, bail
if ( 0 !== strpos( $inner, $start ) ) {
return $inner;
}
$datetime_separator = tribe_get_option( 'dateTimeSeparator', ' @ ' );
$remove_this = tribe_get_start_date( $event_id, false, '' ) . $datetime_separator;
$inner = str_replace( $remove_this, '', $inner );
return $inner;
}
add_filter( 'tribe_events_event_schedule_details_inner', 'cliff_tribe_remove_day_from_start', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.