我必须计算图元键中包含的自定义post type日期的次数:metakey_AMC_data
, 它与当前日期相同,属于特定的分类法
我无法让它工作:
尝试1:这样,我有4个结果,但不是事实,因为我只有一个
<?php
$mostra_data_corrente = date(\'d-m-Y\');
$args = array(
\'post_type\' => \'eventi-suite\',
\'meta_query\' => array(
array(
\'key\' => \'metakey_AMC_data\',
\'type\' => \'DATE\',
\'meta_value\' => $mostra_data_corrente,
)
),
\'tax_query\' => array(
array(
\'taxonomy\' => \'categoria\',
\'field\' => \'slug\',
\'terms\' => $queried_object,
)
),
\'post_status\' => \'publish\',
);
$query = new WP_Query( $args );
$conta_risultati = count($args);
echo $conta_risultati;
?>
尝试2:我无法确定分类法的哪一部分,而为id这样做是疯狂的
global $post;
$show_id = $post->ID;
$mostra_data_corrente = date(\'d-m-Y\');
global $wpdb;
$query = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}postmeta, {$wpdb->prefix}term_relationships
WHERE (meta_key = \'metakey_AMC_data\'
AND meta_value = \'$mostra_data_corrente\'
AND object_id = $show_id) ");
$conta_risultati = count($query);
我只想计算一下(d-m-y)格式的元键的日期在db中出现了多少次,只有来自给定分类法的帖子