• Sam

    (@forbiddenchunk)


    Is it possible to use an advanced custom fields pro date field to organise events on the calendar?

    I have a field called start_date and want to use that instead of the published date.

    Is that possible, please?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Use this code:

    //Remove the custom where clause before the calendar query is executed
    function hubbubart_calendar_remove_posts_where() {
        remove_filter( 'posts_where', 'wpfc_temp_filter_where' );
    }
    
    add_action('wpfc_before_wp_query', 'hubbubart_calendar_remove_posts_where', 10);
    
    function change_calendar_item_date($item, $post){
    
        $ini = date("Y-m-d\TH:i:s", strtotime(get_field('start_date', $post->ID)));
        $fi = date("Y-m-d\TH:i:s", strtotime(get_field('end_date', $post->ID)));
    
        $item['start'] = $ini;
        $item['end'] = $fi;
    
        return $item;
    }
    
    add_filter('wpfc_ajax_post', 'change_calendar_item_date', 10, 2);

    Hi! I have this ACF date-time format: d/m/Y | H:i
    I can’t find the way to make this work, event using this code:

        $ini = date("d/m/Y \ H:i", strtotime(get_field('datahora_prova', $post->ID)));
        $fi = date("d/m/Y \ H:i", strtotime(get_field('datahora_prova', $post->ID)));

    Thanks.

    Hi @mcostadada,

    I’m using this code, and seem to work as it shows the first upcoming event, but it doesn’t show the other events:

    //Remove the custom where clause before the calendar query is executed
    function hubbubart_calendar_remove_posts_where() {
        remove_filter( 'posts_where', 'wpfc_temp_filter_where' );
    }
    add_action('wpfc_before_wp_query', 'hubbubart_calendar_remove_posts_where', 10);
    
    function change_calendar_item_date($item, $post) {
    
        $ini = date("d/m/Y H:i:s", strtotime(get_field('start_date', $post->ID)));
        $fi = date("d/m/Y H:i:s", strtotime(get_field('end_date', $post->ID)));
    
        $item['start'] = $ini;
        $item['end'] = $fi;
    
        return $item;
    }
    
    add_filter('wpfc_ajax_post', 'change_calendar_item_date', 10, 2);

    Any slution to this issue?

    When you add the code the number of events to show per day settings becomes the setting for the total calendar. I had to set that to 200 and then all my events displayed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘ACF date for calendar’ is closed to new replies.