I tried this code which I made but looks like I am not doing it correctly..
The main problem is my code fetches all posts ordered by meta value date, but I need to hide the posts from the date today (which I am unable to do), so I did this from php strtotime (which is also fine), but the main issue is I need only 5 latest posts...
If some one can give a tip to get this code to work it would be great
echo '<ul class="whats-on" id="owl-demo">';
global $wp_query;
$tDate = strtotime('now');
$query = new WP_Query(
array(
'post_type' => 'event',
'posts_per_page' => 999,
'post_status' => 'publish',
'meta_key'=>'event_date',
'orderby' => 'meta_value',
'order' => ASC
)
);
$count = 0;
while ( $query->have_posts() ) : $query->the_post();
$database_date = get_field('event_date');
if( strtotime($database_date) > strtotime('now') ) {
$count++;
if ($count !="6") {
echo '<li class="item">';
echo '<a href="' . the_permalink() . '">';
echo '<img src="' . bloginfo('template_url') . '/timthumb.php?src=' . the_field('cover') . '&w=170&h=228" class="img-responsive">';
echo '<h2>' . get_the_title() . '</h2><p>';
$originalDate = get_field('event_date');
$newDate = date("l M d", strtotime($originalDate));
echo $newDate . '</p></a></li>';
}
}
endwhile;
wp_reset_postdata();
echo '</ul>';