i want to display posts every specific day like post should desplay in evry friday with meta key acf date picker
<?php
$todayName = date('l');
$schedules = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'serie',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'status',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'release_date' ,
'value' => date('l'),
'compare' => '=',
'type' => 'DATE',
),
),
));
?>
i want to display posts every specific day like post should desplay in evry friday with meta key acf date picker
<?php
$todayName = date('l');
$schedules = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'serie',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'status',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'release_date' ,
'value' => date('l'),
'compare' => '=',
'type' => 'DATE',
),
),
));
?>
Share
Improve this question
asked Jul 12, 2019 at 22:46
Kais BOKais BO
1
2
|
1 Answer
Reset to default 0You need to specify the return-format of the acf-field as 'l'
& then modify your query as follows:
$todayName = date('l');
$schedules = new WP_Query([
'posts_per_page' => -1,
'post_type' => 'serie',
'meta_query' => [
'relation' => 'AND',
[
'key' => 'status',
'value' => '1',
'compare' => '=',
],
[
'key' => 'release_date' ,
'value' => '"'.todayName.'"',
'compare' => 'LIKE',
// You might try this too. If you can use this instead of `LIKE` please do, because it's more efficient
// 'value' => todayName,
// 'compare' => '=',
]
]
]);
'compare' => 'LIKE', 'value' => '"'.date('l').'"'
. Could you post is being saved to the db by that acf-field? – admcfajn Commented Jul 13, 2019 at 0:20