php - 根据一个月中的日期查询自定义帖子类型的日期
问题描述
我正在使用自定义帖子类型(CPT)good-posts
。此 CPT 下的每个帖子都有一个自定义字段good_date
,可以保存以下值:YYYY-MM-DD 或 ie:2018-06-28。我试图创建一个带有帖子的月历每天。日历上有帖子的日期会有不同的颜色。如何检索日历上每一天的帖子?我需要每 30 天使用一次 WP_Query() 吗?我认为这需要很长时间。
这是我正在关注的 php 日历... https://stackoverflow.com/a/5537163
解决方案
You can store all the posts with respective date as a query result. Then while rendering the calender check for date in result using
in_array($date, $result);
then apply the color.if date is present in result array.