My head is clearly not working here. The logic is simple but I can’t seem to get it right.
I have a tv schedule post type and I want to display:
2016-12-01
2017-04-01
2017-05-17
Instead of:
2016-12-01
2017-03-01
2017-03-01
2017-03-01
2017-03-01
2017-03-01
At the moment I am stuck with repeating times. I want to only show one time if it already exists as in the first case.
This is my code:
`<?php
$args = array(
'post_type' => 'tv-schedule',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC',
'post_status' => array('publish', 'future'),
);
$posts_array = query_posts($args);
foreach ($posts_array as $post_array) {
$date = $post_array->post_date_gmt;
$new_date = date ('Y-m-01', strtotime($date) );
echo $new_date . '<br />';
/*
if(!in_array($new_date, $post_array->post_date_gmt)){
//$a[]=$value;
echo "test";
}
*/
}`