\WP_Stager_Integration\Calendar::component_day(int $year, int $month, int $day, array $all_events = null, array $args = array()): void

Description

Render a single day view of events.

Extracts only the events for the given year/month/day from the provided hierarchy. If no events exist, an empty list is passed to the template.

Parameters:

ParameterTypeDescription
$year int The year (e.g. 2025).
$month int The month number (1–12).
$day int The day number (1–31).
$all_events array Nested hierarchy of events (year → month → day).
$args array (Optional) Additional arguments to pass to the component template.

Returns:

void

Information

Fileclass-calendar.php line 1923

Full Code

/**
 * Render a single day view of events.
 *
 * Extracts only the events for the given year/month/day
 * from the provided hierarchy. If no events exist, an empty
 * list is passed to the template.
 *
 * @param int   $year           The year (e.g. 2025).
 * @param int   $month          The month number (1–12).
 * @param int   $day            The day number (1–31).
 * @param array $all_events     Nested hierarchy of events (year → month  → day).
 * @param array $args           (Optional) Additional arguments to pass to the component template.
 *
 * @return void
 */
public static function component_day( $year, $month, $day, $all_events = null, $args = array() ) {

    // Type casting
    $year       = (int) $year;
    $month      = (int) $month;
    $day        = (int) $day;
    $all_events = (array) $all_events;
    $args       = (array) $args;

    // Extract only this day's events
    $events = (array) ($all_events[ $year ][ $month ][ $day ] ?? array());

    self::render_calendar_component( 'day', array(
        'year'           => $year,
        'month'          => $month,
        'day'            => $day,
        'events'         => $events,
        'component_args' => $args,
    ) );
}

šŸ’” If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration

šŸŽ Limited offer: Use code WELCOME26 to get your first month for free!