Hello @kiranime,
Thank you for your query and we are so sorry about the trouble this must have caused.
We would like to ask for further details when this issue is happening. Can you please let us know the complete steps you did until you discover that our plugin is changing the query?
Also, share with us the custom taxonomy query code you have on your website.
We really look forward to hearing back from you. Thank you.
- my user inform me that the taxonomy (genre) page is empty.
- I tried to debug using debug log and notice that the request query does not include relationship.
- as usual for debugging, I deactivate all plugin and try one by one.
- all seems good and i get the correct query request, untill i activate rank math then the query changed.
the query:
[
'post_type'=> 'anime',
'post_status'=> 'publish',
'paged' => $page,
'tax_query' => [
[
'taxonomy' => $tax_name,
'field' => 'term_id',
'terms' => $id,
'operator' => 'IN'
]
],
'posts_per_page' => get_theme_mod('__archive_count', 20)
]
I think i know the different, the tax query is way off if the plugin active.
$current = get_queried_object();
$id = $current->term_id;
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$tax_name = $current->taxonomy;
the query (in json from echo):
"query": {
"post_type": "anime",
"paged": 1,
"tax_query": [
{
"taxonomy": "genre",
"field": "term_id",
"terms": 27,
"operator": "IN"
}
],
"posts_per_page": 20
}
tax_query without the plugin:
"tax_query": {
"queries": [
{
"taxonomy": "genre",
"terms": [27],
"field": "term_id",
"operator": "IN",
"include_children": true
}
],
"relation": "AND",
"queried_terms": {
"genre": {
"terms": [27],
"field": "term_id"
}
},
"primary_table": "wp_posts",
"primary_id_column": "ID"
},
With the plugin active, the $id variable is different. in the correct query it’s 27 but if plugin active, the $id will be 227 even if i am using get_queried_object_id() or using $current->term_id.
I found out the issue, the get_header() must be on top of the file. Otherwise, and i don’t know why it’ll change the queried id.
Hello @kiranime,
You mention that with the plugin active you get the value of the queried object with a different ID. Can you please let us know what the ID that you get with the plugin enabled refers to? Is that a page that belongs to this custom taxonomy?
This would help us better understand what might be changing the current WP Query from our side.
Thank you.
when the plugin active the term_id become 227…
Hello @kiranime,
Can you please confirm if the ID(227) belongs to a different term or a page that belongs to this custom taxonomy?
Looking forward to helping you.