admin管理员组文章数量:1420145
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' => '=',
]
]
]);
本文标签: advanced custom fieldsDisplay posts every specific day
版权声明:本文标题:advanced custom fields - Display posts every specific day 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745324385a2653521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
'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