Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
    
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 Sep 26 '12 at 16:35

2 Answers 2

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.

share|improve this answer

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.