比较Wordpress Wp_Query中的日期值

问题描述

我正在运行一个WordPress网站,其中包含约35 000个海关职位。 每个帖子都有一个生日起息日(格式为DD / MM / YYYY),存储在名为生日的ACF字段中

示例:

$birtday_date = get_field("birthday"); //example 02/07/1955

我想运行2个查询,以便将每个帖子的生日值与我的wordpress中的34999个其他生日日期值进行比较,计算并显示老年人的数量。 这是我的代码,但是由于我不太了解如何比较值而无法使用

您能帮我吗?

<?php
$args = array(  // args and query to look for older people that $birthday_date
'posts_per_page' => -1,'post_type' => 'people','meta_key' => 'birthday','meta_value' => $birthday_date,'compare' => '>','type' => 'DATE'

);
$query = new WP_Query($args);
$superior = $query->found_posts;
wp_reset_query();



$args2 = array(  // args and query to look for younger people that $birthday_date
'posts_per_page' => -1,'compare' => '<','type' => 'DATE'

);
$query2 = new WP_Query($args2);
$inferior = $query2->found_posts;
wp_reset_query();

echo $superior; // should display the number of older people but display number of people born the same day than $birthday_date
echo $inferior; // should display the number of younger people but display number of people born the same day than $birthday_date

感谢您的帮助。

致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)