Php Wordpress-将所有有未来日期的帖子计算到当前日期
我正在寻找有计数的所有职位,在未来的日期有到目前的一个 查询:Php Wordpress-将所有有未来日期的帖子计算到当前日期,php,wordpress,Php,Wordpress,我正在寻找有计数的所有职位,在未来的日期有到目前的一个 查询: <?php $mostra_data_corrente = date('d-m-Y'); $query = new WP_Query( array( 'post_type' => get_option('customer_postquery'), 'post_status' => 'publish', 'meta_query' => array(
<?php
$mostra_data_corrente = date('d-m-Y');
$query = new WP_Query( array(
'post_type' => get_option('customer_postquery'),
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'metakey_AMC_data',
)
),
'date_query' => array(
'after' => $mostra_data_corrente,
),
'tax_query' => array(
array(
'taxonomy' => 'categoria',
'field' => 'slug',
'terms' => $queried_object,
)
) ) ) ;
$conta_risultati = $query->found_posts;
echo $conta_risultati;
?>
结果:3,但这不是事实,因为对于这个分类法,在当前日期之后我有7个结果,您可能需要像这样查询它们:
$currentPostDate = 'get your post date here';
$args = array(
'post_type' => 'post',
'meta_key' => 'the_date',
'meta_query' => array(
array(
'key' => 'the_date',
'value' => $today,
'compare' => '>='
)
),
);
$your_custom_query = new WP_Query($args);
$postcount = count($your_custom_query);
考虑将其作为functions.php文件中的函数。那么,实际的具体问题是什么?你需要解释一下你尝试过的东西有什么问题。@04FS我想从我发布问题的那一刻起就很容易理解,与当前帖子相比,它不能完全计算未来某个日期存在多少帖子。我认为您可以在date中尝试使用before和after方法_query@Jinesh我在今天之前和之后都试过了,但都没用:(你能重复这个东西吗?)get_选项(“customer_postquery”);?
$currentPostDate = 'get your post date here';
$args = array(
'post_type' => 'post',
'meta_key' => 'the_date',
'meta_query' => array(
array(
'key' => 'the_date',
'value' => $today,
'compare' => '>='
)
),
);
$your_custom_query = new WP_Query($args);
$postcount = count($your_custom_query);