Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi guys,
    I was using PODS to create my custom fields and was able to get the start and end date from the custom fields by adding the following code in my functions.php

    function event_calender_custom_dates($item, $post){
    		$id = $post->ID;
    		$title = get_the_title($post->ID);
    		$color = "#ad1213";
    		$trade_event = pods("trade_events", $id);
    		$date_from = $trade_event->field("event_date");
    		$date_to = $trade_event->field("to_date");
    	    $post_timestamp = strtotime($date_from);
    	    $end_timestamp = strtotime($date_to);
    		$item = array ("title" => $title, "color" => $color, "start" => date('Y-m-d\TH:i:s', $post_timestamp), "end" => date('Y-m-d\TH:i:s', $end_timestamp), "url" => get_permalink($post->ID), 'post_id' => $post->ID );
    		return $item;
    	}
    	add_filter('wpfc_ajax_post', 'event_calender_custom_dates', 10, 2);

    if someone is using ACF, then replace the pods part with get_field(‘your_custom_field_name’, $post_id)

    Good Luck.

Viewing 1 replies (of 1 total)