ACF Date Picker
dodanie daty:
<?php $event_date = get_field('date', false, false); if( !empty($event_date) ): ?> <?php echo $event_date->format('l, F j, Y'); ?> <?php endif; ?>
formatowanie daty:
<?php $event_date = get_field('date', false, false); $event_date = new DateTime($event_date); if( !empty($event_date) ): ?> <br/> <?php echo $event_date->format('l, F j, Y'); ?> <?php endif; ?>
sortowanie custom post po dacie:
<?php $args = array( 'post_type' => 'event', 'posts_per_page' => -1, 'meta_key' => 'date', 'orderby' => 'meta_value_num', 'order' => 'ASC' ); ?> <?php $eventPosts = new WP_Query( $args ); ?> <?php if ($eventPosts -> have_posts()) : ?> <?php while( $eventPosts->have_posts() ) : $eventPosts->the_post(); ?> <div class="post-event"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail('full'); } ?> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php $event_date = get_field('date', false, false); $event_date = new DateTime($event_date); if( !empty($event_date) ): ?> <br/> <?php echo $event_date->format('l, F j, Y'); ?> <?php endif; ?> </p> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> <?php endif; ?>
Hope this helps and happy coding :)