我正在尝试在我的投资组合模板页面中仅显示名为投资组合的自定义帖子的某些类别。我只能通过slug显示1个类别,但我需要显示超过1个,我想知道是否有办法按ID来过滤类别。
CODE
global $wp_query;
$portfolio_items = $sd_data['portfolio_items']; // Get Items per Page Value
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => $portfolio_items,
'post_status' => 'publish',
'orderby' => 'date',
'paged' => $paged
);
// Only pull from selected taxonomy
$selected_taxonomies = rwmb_meta('sd_portfolio-taxonomies', 'type=checkbox_list');
if($selected_taxonomies && $selected_taxonomies[0] == 0) {
unset($selected_taxonomies[0]);
}
if($selected_taxonomies){
$args['tax_query'][] = array(
'taxonomy' => 'portfolio_filter',
'field' => 'ID',
'terms' => $selected_taxonomies
);
}
$wp_query = new WP_Query($args);
query_posts( array( 'portfolio_filter' => 'extra', 'posts_per_page' => -1 ) );
正如您所看到的,我只能过滤类别,但我需要过滤超过1,我想知道是否有办法按ID过滤类别