我正在尝试获取分类法“value\\u category”中分类法术语“featured layout”的最新帖子。当我只想返回最新的布局时,以下代码将返回所有“特色布局”:
<?php
$cat_arr = array(
\'test-1\',
\'test-2\',
\'test-3\',
);
$args = array(
\'post_type\' => \'values\',
\'posts_per_page\' => 1,
);
$mobile_posts = get_posts($args);
$count = 0;
foreach ($mobile_posts as $mobile_post) : setup_postdata($mobile_post);
//Getting \'Featured\' Value
$featured_value_cat_query = new WP_Query( array (
\'post_type\' => \'values\',
\'posts_per_page\' => -1,
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'value_layout_position\',
\'field\' => \'slug\',
\'terms\' => \'featured-layout\',
),
array(
\'taxonomy\' => \'value_category\',
\'field\' => \'slug\',
\'terms\' => $cat_arr,
),
),
) );
if ( $featured_value_cat_query->have_posts() ) {
while ( $featured_value_cat_query->have_posts() ): $featured_value_cat_query->the_post();
echo \' | \' . the_title();
endwhile;
}
endforeach;
wp_reset_postdata();
?>
有人知道如何只返回“特色版面”术语中的最新帖子吗?谢谢