Home › Forums › Pro Support › Display Date of Event
Tagged: Event dates
- This topic has 5 replies, 2 voices, and was last updated 4 years, 1 month ago by
Tom.
-
AuthorPosts
-
August 12, 2019 at 2:53 pm #10746
Barb
ParticipantHello!
We have really appreciated the usefulness of your plugin!We would like to display upcoming events (using ID’s) with their event date. https://thelocaldish.com/food-and-drink-festivals-oregon/.
However, the date being displayed is the published date rather than the event date, and all events on that page are upcoming. As a result the events are displaying by publish date (all of which were in the past) rather than chronologically by event occurrence. Do you have a suggestion on how to change that?
Thanks!
BarbAugust 12, 2019 at 5:13 pm #10753Tom
KeymasterHi Barb,
Where is the event date coming from? Is it post meta from a plugin? If so, which one?
August 12, 2019 at 5:41 pm #10754Barb
ParticipantWe’re using Geodirectory software on WordPress. New Events are entered using the Geodirectory Events plugin. The Event Start Date is a standard field in the Add New Event editor. So yes, I guess it would be considered meta for the event custom post type.
August 13, 2019 at 5:20 pm #10763Tom
KeymasterI just looked around their forums to find what field to query, but I couldn’t find anything. You might need to ask their support what the
get_post_meta()
name is that we need to use.August 14, 2019 at 11:16 am #10773Barb
ParticipantHi Tom,
Geodirectory said “they don’t have a separate key for start_date. We have already task in our todo to allow show start date, end date, start time & end time. It will be in one of our future versions.”“Right now to achieve that (show start date) you want do following things.
1) Add following PHP snippet via plugin or theme functions.php file
function gd_snippet_190814_output_event_dates( $output, $find_post, $args ) {
global $post;$the_post = ! empty( $find_post->start_date ) ? $find_post : ( ! empty( $post ) && ! empty( $post->start_date ) && $post->ID == $find_post->ID ? $post : NULL );
if ( ! empty( $the_post ) && ! empty( $the_post->start_date ) && strpos( $args[‘badge’], ‘%%event_’ ) !== false ) {
$date_format = geodir_event_date_format();
$time_format = geodir_event_time_format();$output = $args[‘badge’];
$output = str_replace( ‘%%event_start_date%%’, date_i18n( $date_format, strtotime( $the_post->start_date ) ), $output );
$output = str_replace( ‘%%event_end_date%%’, date_i18n( $date_format, strtotime( $the_post->end_date ) ), $output );
$output = str_replace( ‘%%event_start_time%%’, date_i18n( $time_format, strtotime( $the_post->start_time ) ), $output );
$output = str_replace( ‘%%event_end_time%%’, date_i18n( $time_format, strtotime( $the_post->end_time ) ), $output );
}return $output;
}
add_filter( ‘geodir_output_badge_field_key_event_dates’, ‘gd_snippet_190814_output_event_dates’, 20, 3 );2) Use following shortcodes:
– For start date: [gd_post_badge key=”event_dates” condition=”is_not_empty” badge=”%%event_start_date%%” bg_color=”#ffffff” txt_color=”#1339f0″ alignment=”center”]
– For end date: [gd_post_badge key=”event_dates” condition=”is_not_empty” badge=”%%event_end_date%%” bg_color=”#ffffff” txt_color=”#1339f0″ alignment=”center”]It makes more sense for us to show the event start date and end date so I’m providing both the shortcodes from Geodirectory.
Let me know if the snippet and codes do or don’t make sense.
Thanks!
August 14, 2019 at 5:08 pm #10775Tom
KeymasterI’m not 100% sure it will work, but you could try this:
add_filter( 'wpsp_date_output', function( $output ) { return sprintf( '<span class="wp-show-posts-posted-on wp-show-posts-meta"> %1$s %2$s </span>', do_shortcode( '[gd_post_badge key="event_dates" condition="is_not_empty" badge="%%event_start_date%%" bg_color="#ffffff" txt_color="#1339f0" alignment="center"]' ), do_shortcode( '[gd_post_badge key="event_dates" condition="is_not_empty" badge="%%event_end_date%%" bg_color="#ffffff" txt_color="#1339f0" alignment="center"]' ); ); } );
You’ll also need to add the snippet they provided.
-
AuthorPosts
- You must be logged in to reply to this topic.