Wordpress通过备用子字段查询邮政订单
我使用的是ACF PRO的中继器功能,它允许在一个帖子中使用一个或多个子字段。我正在利用这一功能,以便内容编辑器可以为一篇文章分配多个日期,并为每个日期指定优先级(高=1,低=0) 下面的代码查询指定日期与今天日期匹配的帖子然后我想对帖子进行排序,以便首先列出指定日期优先级为1的帖子一切正常,但当我有多个指定日期/优先级的帖子时,查询只使用它获得的第一个优先级值,而不只是指定给特定(今天)日期的优先级值 我需要以某种方式确定行#分配的日期是从哪里开始的,这样我就只能使用该子行的优先级值。任何帮助都将是惊人的!提前谢谢你强>Wordpress通过备用子字段查询邮政订单,wordpress,repeater,custom-fields,advanced-custom-fields,Wordpress,Repeater,Custom Fields,Advanced Custom Fields,我使用的是ACF PRO的中继器功能,它允许在一个帖子中使用一个或多个子字段。我正在利用这一功能,以便内容编辑器可以为一篇文章分配多个日期,并为每个日期指定优先级(高=1,低=0) 下面的代码查询指定日期与今天日期匹配的帖子然后我想对帖子进行排序,以便首先列出指定日期优先级为1的帖子一切正常,但当我有多个指定日期/优先级的帖子时,查询只使用它获得的第一个优先级值,而不只是指定给特定(今天)日期的优先级值 我需要以某种方式确定行#分配的日期是从哪里开始的,这样我就只能使用该子行的优先级值。任何帮助
如果您不熟悉ACF Repeater功能,他们会对重复子字段使用由三部分组成的命名约定:
<?php
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'ssm_assign_%", "meta_key LIKE 'ssm_assign_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$datetoday = current_time('Ymd');
$args = array(
'posts_per_page'=> 2,
'post_type' => 'ssm',
'meta_query' => array(
'relation' => 'AND',
'assigned_dates' => array(
'key' => 'ssm_assign_%_ssm_assigned_date',
'compare' => '=',
'value' => $datetoday,
),
'assigned_priorities' => array(
'key' => 'ssm_assign_%_ssm_date_priority',
'compare' => 'EXISTS',
),
),
'orderby' => 'assigned_priorities',
'order' => 'DESC',
);
// query
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
// Start the loop.
while ( $the_query->have_posts() ) : $the_query->the_post();
include(locate_template('content.php'));
endwhile;
// End the loop.
get_template_part( 'content', 'none' );
endif; //End of customized current day posts
wp_reset_query(); // Restore global post data stomped by the_post().
?>