Home Forums Front-end Issues Widget Calendar and Date field


Widget Calendar and Date field

  • Hi,

    I use a date field (date picker) for my post as an event date.

    I’d like to get this field in the default widget calendar instead of the post_date.

    Could someone help me please ?


  • There isn’t any way to do this in ACF. What you’re going to need to do is to create a new custom widget. You can start by copying the existing calendar widget /wp-includes/widgets/class-wp-widget-calendar.php

    WP Widget API doc:
    Widget turorial:

  • Hi John,

    Thanks a lot for your answer, i’m just surprised there no third party solution, because i suppose it’s a basic need, using and sorting in widget calendar with ACF date field instead of wp post_date.

  • The problem is really that there are no suitable hooks in the built in WP widgets that will let you do anything to modify them. I’ve run into the same thing when I’ve needed other widgets, like a date or category widget for a custom post type.

  • Ok thanks i understand, so i’ve used a wp calendar widget clone( and i think
    instead of using :
    // Get days with posts

      $dayswithposts = $wpdb->get_results( "SELECT DISTINCT DAYOFMONTH( post_date )
        FROM $wpdb->posts WHERE MONTH( date ) = '$thismonth'
        AND YEAR( post_date ) = '$thisyear'
        AND post_type IN ( $post_types ) AND post_status = 'publish '"
            , ARRAY_N );

    i suppose i musts do something like :

    $args = array (
      'post_type'      => 'post',       // your custom post type
      'meta_key'       => 'date_de_la_manifestation',  // your custom date field name
      'orderby'        => 'meta_value_num',
      'order'          => 'ASC',
      'meta_query' => array(
          'key'      => 'date_de_la_manifestation',
          'compare'  => 'REGEXP',
          'value'    => '[0-9]{4}' . $thismonth . '[0-9]{2}',

    and after make a loop on result to get the day of my acf field date_de_la_manifestation and displays it in the calendar.

  • Or if you know how you can use $wpdb as in the first code example and extend the query to join the meta table. Both will result in the same but $wpdb will be faster.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Widget Calendar and Date field’ is closed to new replies.