Home › Forums › General Issues › Difficulties to sort a post by DatePicker › Reply To: Difficulties to sort a post by DatePicker
Yes I tried but it didn’t work, nothing appears.
The
echo '<pre>'; print_r($posts); echo '</pre>';
display me the array with all data and for the
global $post;
there’s nothing that appears.
To be sure I show you where I put it in my code :
<?php global $post; ?>
<?php $posts = get_posts(array(
'post_type' => 'post',
'posts_per_page' => -1,
'meta_key' => 'start_date',
'orderby' => 'meta_value_num',
'order' => 'DESC'
));
if( $posts ): ?>
<?php foreach( $posts as $post ):
setup_postdata( $post )
?>
<?php $now = time();
$date_one_timestamp = strtotime(get_field('end_date', false, false));
if ($now < $date_one_timestamp ) { ?>
<div class="event-total-page">
<div class="category-name-event"></div>
<div class="date-time">
<div class="date-custom-page">
<?php $dateformatstring = '<p>j</p> <p>F Y</p>'; ?>
<?php $unixtimestamp = strtotime(get_field('start_date', false, false));
echo date_i18n($dateformatstring, $unixtimestamp); ?>
<a href="<?php the_permalink(); ?>"><p class="view-event btn-primary">BEKIJK EVENT</p></a>
</div>
</div>
Even if I try it in another place it doesn’t work.
Thanks a lot John for your time.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.