I'm using the ACF (Advanced Custom Fields) and selected the date picker.
I'm wondering if anyone has created a simple calendar plugin that can grab the field and produce a calendar. How should I do that?
I'm using the ACF (Advanced Custom Fields) and selected the date picker.
I'm wondering if anyone has created a simple calendar plugin that can grab the field and produce a calendar. How should I do that?
As @Vincius mentioned above, I don't think anyone has created a full-blown calendar with ACF and ACF alone. But - that doesn't mean you can't plug into other Event Calendars (or --> attach the ACF data onto their Events post type). For example:
Sugar Event Calendar
Hooks
) that allow you to override each query generated by the plugin. That way, if you had another post type, you could override the default query from post_type => 'events'
to post_type => array('events','your_post_type')
But, if you use the second example and just add-on additional data you need, every decent event plugin will allow you to override the respective views for each area - and you can then use normal ACF functions to output your data. Thanks!
I don't know any plugin like this. Anyway, you should provide specific information of what kind of calendar you want. By general means, strtotime
is your friend.
For example, to generate a day listing of the current month with a highlighted date from the custom field, you would do something like:
$date_field = date( 'Y-m-d', strtotime( get_field( 'date_field' ) ) );
$current_month = date( 'Y-m-' );
for ( $day = 1; $day < date( 't' ); $day++ ) {
$day_of_month = $current_month . $day;
if ( $day_of_month == $date_field )
<span class="highlight"><?php echo $day_of_month; ?></span>
else
<span class="normal"><?php echo $day_of_month; ?></span>
}
Note: the above code is not tested.