• Hey guys,

    Not really a question, just wanted to push this out into the world as a solution to something I was having difficulty with. If you want to use an Events custom field and then display the events in FullCalendar, it will pull through the post date and not the event date.

    I made these three tweaks and the calendar started pulling through the event date.

    Comment out this line (for me it was at line 186):
    //$where .= $wpdb->prepare(” AND post_date >= %s AND post_date < %s”, $_REQUEST[‘start’], $_REQUEST[‘end’]);

    Then add this line around line 196 under $color and before $post_date:

    $time_date = get_field(‘your_acf_date‘);

    And use this new parameter to modify the following lines below:

    $post_date = substr($time_date, 0, 10);
    $post_timestamp = strtotime($time_date);

    And voila! Perfect to use if you just want to update dates and don’t need to be messing around with the actual time an event starts.

    Hope it help!

    • This topic was modified 7 years, 5 months ago by charliejustus.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks. But nothing new ??

    Thread Starter charliejustus

    (@charliejustus)

    Nice! How the hell did I miss that?

    I had to do this same thing but I didn’t want to modify the plugin core. In my case start time and end time was the same value and I used a custom field for both date and time. I ended up doing it this way:

    Inside functions.php

    if(class_exists("WP_FullCalendar")) {
    	//Remove the custom where clause before the calendar query is executed
    	function remove_posts_where() {
    	    remove_filter( 'posts_where', 'wpfc_temp_filter_where' );
    	}
    	add_action('wpfc_before_wp_query', 'remove_posts_where', 10);
    
            //Override the item timestamp
    	function change_item_date($item, $post) {
    
    		$new_post_timestamp = date("Y-m-d\TH:i:s", strtotime(get_field('date', $post->ID) . ' ' . get_field('time', $post->ID)));
    
    		$item['start'] = $new_post_timestamp;
    		$item['end'] = $new_post_timestamp;
    
    		return $item;
    	}
    	add_filter('wpfc_ajax_post', 'change_item_date', 10, 2);
    }
    • This reply was modified 7 years, 5 months ago by Dan Shedd.

    I cannot get it to work with this snippet, no matter what I tried.
    CHanged value of some Posts and resaved them, just to exclude transients caching.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Advanced Custom Fields Date instead of Post Date’ is closed to new replies.