我想在每一个特定的日子显示帖子,比如帖子应该在每个星期五用meta键acf日期选择器显示
<?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\',
),
),
));
?>
SO网友:admcfajn
您需要将acf字段的返回格式指定为“l”
&;然后按如下方式修改查询:
$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\' => \'=\',
]
]
]);