display event date on card (custom field)?
-
I would like to display a grid of events with its date above the title. My events are no more than woocommerce product, so in essence, it’s a product list.
But I need to get its date from a custom field created by FooEvents.
They provide a snippet to use within woocommerce.
Can you pls help transpose it to your plugin?
“Display the event date before the title on the product page
function fooevents_display_date_on_single() {
global $post;
$product = wc_get_product( $post->ID );
$start_date = $product->get_meta( 'WooCommerceEventsDate' );
$end_date = $product->get_meta( 'WooCommerceEventsEndDate' );
if ( $end_date ) {
printf(
'<h3>%s</h3>',
esc_html( $start_date . ' - ' . $end_date )
);
} else if( $start_date ) {
printf(
'<h3>%s</h3>',
esc_html( $start_date )
);
}
}
add_action( 'woocommerce_single_product_summary', 'fooevents_display_date_on_single' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘display event date on card (custom field)?’ is closed to new replies.