我使用ACF Pro Repeater字段,我在数据库中的自定义字段名称为seminars_details_0_start_date,seminars_details_1_start_date等
下面是我使用的代码
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'seminars_details_$", "meta_key LIKE 'seminars_details_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$args = array(
// 'numberposts' => ,
'posts_per_page'=> '-1',
'post_type' => 'training',
'meta_key' => 'seminars_details_$_start_date',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'seminars_details_$_start_date',
'value' => array('20230101' , '20231231'),
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
),
)
);
$the_query = new WP_Query( $args );
1条答案
按热度按时间3htmauhk1#
首先,你的代码中有一些缺陷.尝试用下面的代码替换$args-