Answer the question
In order to leave comments, you need to log in
"pre_get_posts" how to get posts from the required category with taxonomy?
Hello!
Tell me how to get posts from a certain category "56k-modems", where the
"billion" tag is specified in the "brand" taxonomy.
The code I'm trying to change the selection of posts.
add_action( 'pre_get_posts', 'my_pre_get_posts' );
function my_pre_get_posts( $query ){
if($query->is_archive && isset($query->query["category_name"]) ){
$taxquery = array(
array(
'taxonomy' => 'brand',
'field' => 'slug',
'terms' => 'billion',
'operator'=> 'AND'
)
);
$query->set( 'tax_query', $taxquery );
$query->set('category_name', '56k-modems');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question