apply_filters( ‘get_calendar_args’, array $args )

Filter the get_calendar function arguments before they are used.

Parameters

$argsarray
Arguments for the get_calendar function.
  • initial bool
    Whether to use initial calendar names. Default true.
  • display bool
    Whether to display the calendar output. Default true.
  • post_type string
    Optional. Post type. Default 'post'.

Source

$args = apply_filters( 'get_calendar_args', wp_parse_args( $args, $defaults ) );

Changelog

VersionDescription
6.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    The get_calendar_args filter allows you to modify the arguments passed to the get_calendar() function before the calendar is built. This is useful for changing the post type used, disabling the initial calendar names, or overriding other default options.

    Example: Display calendar using a custom post type

    add_filter( 'get_calendar_args', function( $args ) {
        $args['post_type'] = 'event';
    
        return $args;
    } );

    Example: Disable initial calendar names (month headings)

    add_filter( 'get_calendar_args', function( $args ) {
        $args['initial'] = false;
    
        return $args;
    } );

    This filter is helpful when integrating custom post types (like events or courses) into your theme’s calendar, or when you want to control display behavior globally without modifying every get_calendar() call.

You must log in before being able to contribute a note or feedback.