Support

Account

Home Forums General Issues Date Picker – calendar

Unread

Date Picker – calendar

  • Hey guys,

    I’m looking to achieve the following using the acf date picker and a custom post-type.

    As a post gets added to the custom post type ‘booking’ with a date. This gets assigned a specific e.g class, y/m/d.

    In a calendar the chosen date turns red because it’s been booked within the ‘booking’ post-type. Currently I only have the date getting returned.

    <?php 
    
        // args
        $args = array(
          'numberposts'	=> -1,
          'post_type'		=> 'booking'
        );
        
        
        // query
        $the_query = new WP_Query( $args );
        
        ?>
        <?php if( $the_query->have_posts() ): ?>
          <ul>
          <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <li>
    
                <?php $date_string = get_field('booking');
    
                // Create DateTime object from value (formats must match).
                $date = DateTime::createFromFormat('Ymd', $date_string);
    
                // Output current date in custom format. ?>
                <p class="">Date: <?php the_field('booking') ?></p>
    
            </li>
          <?php endwhile; ?>
          </ul>
        <?php endif; ?>
        
        <?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.