I have Radio with programs and they are associated to day of the weak.
Example:
1-Program Disco Nights plays at Monday and Friday
2-Pragram Crazy weekends play only at Sunday
3-etc
4-etc
Objective: List All the programs without repeating the ones are associated to multiple days based on current day and the next ones.
If today is Saturday have to list Saturday programs them sunday, monday etc etc but can’t only be listed once the same program. (THE CLOSEST ONE)
How to achieve this?
On the back-office I have a multi select option which allow user to select multiple days based on plugin framework it stores the meta_value in a serialized array and can not be changed so I have to work with it.
a:3:{i:0;s:1:"3";i:1;s:1:"4";i:2;s:1:"6";}
Each day correspond to a value.
0 – Sunday
1 – Monday
2 – Tuesday
3 – Wednesday
4 – Thursday
5 – Friday
6 – Saturday
Now the hardest part to list it on-front office.
$today = date('w');
$args = array(
'post_type' => 'programas',
'meta_key' => 'audio_date',
'orderby' => ' ?? closest one ??',
$the_query = new WP_Query( $args );
);
Remember meta key returns a serialized array like this
a:3:{i:0;s:1:"3";i:1;s:1:"4";i:2;s:1:"6";}
I don’t know how to compare the most closest programs to that day
while ( $the_query->have_posts() ) {
$the_query->the_post();
$items = get_post_meta( $post->ID, 'audio_date', true );
the_title();
if ( is_array($items) ) {
foreach ( $items as $item) :
echo $item;
endforeach;
}
}
Any ideas???? I tried also use post_type categories and make one category for each day but its not working also.