advanced custom fields - Simple Calendar

admin2025-01-08  4

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?

Share Improve this question edited Sep 26, 2012 at 16:33 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Sep 17, 2012 at 9:49 WebDevBWebDevB 11 silver badge1 bronze badge 1
  • Pretty much every events plug-in will allow you to create a calendar. Is there a particular need for it be based on ACF? What exactly are you trying to achieve? – Stephen Harris Commented Sep 26, 2012 at 16:35
Add a comment  | 

2 Answers 2

Reset to default 1

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

  • It has a filter hooks (look on that page, under 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')
  • If you setup your ACF fields and attach them to the Event post type, what you can then do is remove_meta_box() on whatever meta boxes you would like to hide (that would have date info) and then setup your ACF fields to map to the same meta_keys. This one is more dangerous though - as if the dev changes something with how the meta fields are saved, you could run into trouble.

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736269891a1387.html

最新回复(0)