Hi,
I'm experiencing a very weird problem that literally has me stumped.
I have the following query:
$contact_args = array(
'post_type' => 'contact',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'contacts',
'field' => 'slug',
'terms' => 'about-us',
'operator' => 'IN'
)
),
'orderby' => 'date',
'order' => 'ASC'
);
$contacts = new WP_Query($contact_args);
This is working fine in Firefox, but in Chrome and IE I am receiving all posts of the type "contact" regardless of their taxonomy, the "tax_query" part is simply being ignored.
When var_dumping the WP_Query object I created "$contacts" I can see the generated mySQL is different in each browser.
This is all server side, So I am completely clueless how a browser could be affecting the query?
The following vaules are all from the same var_dump, You can see the values are entered correctly in the query array of the WP_Query object, but the WP_Tax_Query object in the WP_Query object differs, as does the MySQL that is being generated.
Generated MySQL and $query below:
query:
Chrome:
["query"]=> array(6) { ["post_type"]=> string(7) "contact" ["post_status"]=> string(7) "publish" ["posts_per_page"]=> int(-1) ["tax_query"]=> array(1) { [0]=> array(4) { ["taxonomy"]=> string(8) "contacts" ["field"]=> string(4) "slug" ["terms"]=> string(8) "about-us" ["operator"]=> string(2) "IN" } } ["orderby"]=> string(4) "date" ["order"]=> string(3) "ASC" }
Firefox:
["query"]=> array(6) { ["post_type"]=> string(7) "contact" ["post_status"]=> string(7) "publish" ["posts_per_page"]=> int(-1) ["tax_query"]=> array(1) { [0]=> array(4) { ["taxonomy"]=> string(8) "contacts" ["field"]=> string(4) "slug" ["terms"]=> string(8) "about-us" ["operator"]=> string(2) "IN" } } ["orderby"]=> string(4) "date" ["order"]=> string(3) "ASC" }
WP_Tax_Query
Chrome:
["tax_query"]=> object(WP_Tax_Query)#6 (2) { ["queries"]=> array(0) { } ["relation"]=> string(3) "AND" }
Firefox:
["tax_query"]=> object(WP_Tax_Query)#353 (2) { ["queries"]=> array(1) { [0]=> array(5) { ["taxonomy"]=> string(8) "contacts" ["terms"]=> array(1) { [0]=> string(8) "about-us" } ["include_children"]=> bool(true) ["field"]=> string(4) "slug" ["operator"]=> string(2) "IN" } } ["relation"]=> string(3) "AND" }
MySQL:
Chrome:
["request"]=> string(154) " SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'contact' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date ASC "
Firefox:
["request"]=> string(312) " SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (7) ) AND wp_posts.post_type = 'contact' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC "
Any advice would be hugely appreciated,
Thanks, Jack