Available Hooks & Filters
"View <post type>" text in calendar popover
Use this filter to change the "View <post type>" text in the calendar popover for all events.
add_filter('piecal_popover_link_text', 'my_callback'); function my_callback( $text ) { $text = "Buy Tickets"; return $text; }
Event query arguments
You can use the following code to change the query that returns all of Pie Calendar's events on the front-end. Below is an example that conditionally changes the post type shown on the calendar based on an arbitrary shortcode attribute.
add_filter('piecal_event_query_args', 'my_callback', 10, 2); function my_callback( $args, $atts ) { if( isset($atts['sandwich']) && $atts['sandwich'] == 'salami' ) { $args['post_type'] = 'game_tournaments'; } return $args; }
Shortcode $atts
You can filter the $atts of the Pie Calendar shortcode using the code below.
add_filter('piecal_shortcode_atts', 'my_callback', 10, 1); function my_callback( $atts ) { if( isset($atts['sandwich']) && $atts['sandwich'] == 'salami' ) { $atts['type'] = 'product'; } return $atts; }
Date format for calendar popover
The date strings output in the Pie Calendar popover are output via toLocaleDateString, which accepts an options array to define the format.
You can manipulate this array using the filters below. Note that there is one filter for the format of dates for events that are not all day events, and one filter for the format of dates that are all day events. This separation is due to the fact that it's often desirable to not show start and end times (hour/minute) for all day events.
add_filter('piecal_locale_date_string_format', 'my_callback'); function my_callback( $format ) { $format['weekday'] = 'short'; // Other possible values: long, short, narrow $format['day'] = 'numeric'; // Other possible values: numeric, 2-digit $format['year'] = 'numeric'; // Other possible values: numeric, 2-digit $format['month'] = 'long'; // Other possible values: numeric, 2-digit, long, short, narrow $format['hour'] = 'numeric'; // Other possible values: numeric, 2-digit $format['minute'] = 'numeric'; // Other possible values: numeric, 2-digit $format['second'] = 'numeric'; // Other possible values: numeric, 2-digit return $format; } add_filter('piecal_allday_locale_date_string_format', 'my_allday_callback'); function my_allday_callback( $format ) { $format['weekday'] = 'short'; // Other possible values: long, short, narrow $format['day'] = 'numeric'; // Other possible values: numeric, 2-digit $format['year'] = 'numeric'; // Other possible values: numeric, 2-digit $format['month'] = 'long'; // Other possible values: numeric, 2-digit, long, short, narrow return $format; }
Add classes to piecal-wrapper div
add_filter('piecal_wrapper_class', function() { return "sandwich"; });
The above code will result in the div being output with the class attribute value "piecal-wrapper sandwich".
Adding or altering popover content
Using the following hooks, you can add anything you want into the Pie Calendar popover.
- piecal_popover_before_title
- piecal_popover_after_title
- piecal_popover_before_meta
- piecal_popover_after_meta
- piecal_popover_before_details
- piecal_popover_after_details
- piecal_popover_before_view_link
To learn how to use these hooks for your own custom content such as ACF fields, read this article: https://docs.piecalendar.com/article/50-using-custom-field-data-in-pie-calendar-popover
If you want to alter or replace the event details that are shown in the popover, you can use the piecal_popover_details
filter. Here's a simple example:
add_filter('piecal_popover_details', function( $content ) { ob_start(); global $post; ?> <p>My new event details.</p> <?php return ob_get_clean(); });