I want fetch all posts from the post type book
in the custom taxonomy book_tags
with the meta key lang
and the meta value en
.
My code:
<?php
$args = array(
'post_type' => 'book',
'posts_per_page' => 40,
'paged' => "$paged",
'meta_query' => array(
array(
'key' => 'lang',
'value' => 'en',
'compare' => 'LIKE'
)
),
'tax_query' => array(
array(
'taxonomy' => 'book_tags',
'field' => 'slug',
'terms' => get_queried_object()->slug
)
)
);
$additional_loop = new WP_Query($args);
while ($additional_loop->have_posts()) :
$additional_loop->the_post();
This doesn’t work? Why?
If I remove "meta_query" it works. Is there a bug in "meta_query"?
pre_get_posts
is a very common solution that people overlook when trying to modify a loop. Though for a start, I'd guess that"$paged"
is wrong (since the variable is in quotes) as might also beget_queried_object()->slug
.meta_query
. Please edit your question to provide more details about what you are trying to do.. and where.