I want to filter my posts by below taxonomy query.
Это код плагина.Внутри фильтра the_posts я использую функцию the_posts.У меня есть 4 продукта в синих таксономических терминах.Возвращает 4 товара, затем весь товар на странице магазина.как я могу справиться с этим?помоги мне ...
function the_posts( $posts, $query = false ){
if ( ! is_main_query() ) return $posts;
$args = array(
'post_type' => 'product',
'numberposts' => -1,
'post_status' => 'publish',
'fields' => 'ids',
'tax_query' => array( array(
'taxonomy' => 'pa_color',
'field' => 'slug',
'terms' => array('blue'),
'operator' => 'IN',
) )
)
if ( $filtered_posts = get_posts( $args ) ) {
$insert = 0;
foreach ( $filtered_posts as $filtered_post ) {
array_splice( $posts, $insert, 0, array( $filtered_post ) );
}
}
return $posts;
}