Home › Forums › General Issues › ACF PRO – Date and compare (merge) › Reply To: ACF PRO – Date and compare (merge)
Hello I solved it
$the_query = new WP_Query( array(
'post_type' => array('town1_event','town1_event2'),
'post_status' => 'publish',
'meta_key' => 'datum_eventu',
'orderby' => 'meta_value_num',
'order' => 'ASC'
) );
# This will hold what group we're in
$current_header = '';
# The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
# get the datum for this post
$temp_date = get_post_meta( get_the_ID(), 'datum_eventu', true );
# If they aren't the same, we'll start a new group, which for now
# just means setting a new heading
if ( $temp_date != $current_header ) {
$current_header = $temp_date;
$old_date = date($current_header); // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('d.m.Y', $old_date_timestamp);
echo "<h2>$new_date</h2>";
}
$nazev = get_field("nazev_eventu");
echo $nazev;
echo "<br/>";
# ... do normal loop stuff here
endwhile;
Inspired on stack over flow
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.