Using Dynamic multiple attributes With WP_Queryadd_magic_quotes() is not working in wordpressIncorrect posts showing through WP-Query on WooCommerceSetting Tax Query in pre_get_posts still showing products with the wrong taxonomyShow posts from custom taxonomyWordPress & BuddyPress Outputting PHP to pageWordpress: Using post__not_in to exclude custom taxonomy categoryHow to Search posts using LIKE for Category Name in wordpress?WP_Query not ordering by titleAdding Alt Tags To CarouselGet image post by taxonomy/category wordpress

Antonym of "Megalomania"

What is the highest achievable score in Catan

Is it possible to tell if a child will turn into a Hag?

Unknown indication below upper stave

Applications of pure mathematics in operations research

Why does the Rust compiler not optimize code assuming that two mutable references cannot alias?

Prepare a user to perform an action before proceeding to the next step

Is it possible for a particle to decay via gravity?

If the Moon were impacted by a suitably sized meteor, how long would it take to impact the Earth?

Why would anyone ever invest in a cash-only etf?

Should I put my name first, or last in the team members list

What is this kind of symbol meant to be?

Boots or trail runners with reference to blisters?

What is a good example for artistic ND filter applications?

Can machine learning learn a function like finding maximum from a list?

Did Vladimir Lenin have a cat?

My employer is refusing to give me the pay that was advertised after an internal job move

Why are subdominants unstable?

Three Dots in Center Page

Can I attune a Circlet of Human Perfection to my animated skeletons to allow them to blend in and speak?

Why did Windows 95 crash the whole system but newer Windows only crashed programs?

What clothes would flying-people wear?

Does Ubuntu reduce battery life?

Move arrows along a contour



Using Dynamic multiple attributes With WP_Query


add_magic_quotes() is not working in wordpressIncorrect posts showing through WP-Query on WooCommerceSetting Tax Query in pre_get_posts still showing products with the wrong taxonomyShow posts from custom taxonomyWordPress & BuddyPress Outputting PHP to pageWordpress: Using post__not_in to exclude custom taxonomy categoryHow to Search posts using LIKE for Category Name in wordpress?WP_Query not ordering by titleAdding Alt Tags To CarouselGet image post by taxonomy/category wordpress






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a form from where clicks on the attribute and based on that click, I change my query to fetch relevant results



Below Array is generated dynamically based on user selection



Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[product_cat] => pads
[posts_per_page] => -1
)


Based on the above array WP_Query generated



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (259,263,274,314)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


But when I just hardcode the array and pass it to WP_Query it produces



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (274)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[field] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


Which I expect WP_Query to produce. the problem is that WP_query is not producing for the dynamic query. Is there something I am missing



$dayArg = array(
'tax_query' => array(
array(
'taxonomy' => 'pa_timing',
'field' => 'slug',
'terms' => array( 'day' )
),
array(
'taxonomy' => 'pa_size',
'field' => 'slug',
'terms' => array( 's' )
)
),
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => - 1,
'product_cat' => 'pads'
)


This is argument I am passing to WP_Query one generating dynamically and one hardcoding it.










share|improve this question


























  • @LoicTheAztec I have updated my question with related WP_Query arguments

    – Mustanish Altamash
    Mar 27 at 10:22












  • I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

    – Mustanish Altamash
    Mar 27 at 17:24

















0















I have a form from where clicks on the attribute and based on that click, I change my query to fetch relevant results



Below Array is generated dynamically based on user selection



Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[product_cat] => pads
[posts_per_page] => -1
)


Based on the above array WP_Query generated



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (259,263,274,314)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


But when I just hardcode the array and pass it to WP_Query it produces



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (274)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[field] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


Which I expect WP_Query to produce. the problem is that WP_query is not producing for the dynamic query. Is there something I am missing



$dayArg = array(
'tax_query' => array(
array(
'taxonomy' => 'pa_timing',
'field' => 'slug',
'terms' => array( 'day' )
),
array(
'taxonomy' => 'pa_size',
'field' => 'slug',
'terms' => array( 's' )
)
),
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => - 1,
'product_cat' => 'pads'
)


This is argument I am passing to WP_Query one generating dynamically and one hardcoding it.










share|improve this question


























  • @LoicTheAztec I have updated my question with related WP_Query arguments

    – Mustanish Altamash
    Mar 27 at 10:22












  • I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

    – Mustanish Altamash
    Mar 27 at 17:24













0












0








0








I have a form from where clicks on the attribute and based on that click, I change my query to fetch relevant results



Below Array is generated dynamically based on user selection



Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[product_cat] => pads
[posts_per_page] => -1
)


Based on the above array WP_Query generated



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (259,263,274,314)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


But when I just hardcode the array and pass it to WP_Query it produces



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (274)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[field] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


Which I expect WP_Query to produce. the problem is that WP_query is not producing for the dynamic query. Is there something I am missing



$dayArg = array(
'tax_query' => array(
array(
'taxonomy' => 'pa_timing',
'field' => 'slug',
'terms' => array( 'day' )
),
array(
'taxonomy' => 'pa_size',
'field' => 'slug',
'terms' => array( 's' )
)
),
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => - 1,
'product_cat' => 'pads'
)


This is argument I am passing to WP_Query one generating dynamically and one hardcoding it.










share|improve this question
















I have a form from where clicks on the attribute and based on that click, I change my query to fetch relevant results



Below Array is generated dynamically based on user selection



Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[product_cat] => pads
[posts_per_page] => -1
)


Based on the above array WP_Query generated



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (259,263,274,314)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[fields] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


But when I just hardcode the array and pass it to WP_Query it produces



SELECT vsrc_posts.* FROM vsrc_posts LEFT JOIN vsrc_term_relationships ON (vsrc_posts.ID = vsrc_term_relationships.object_id) LEFT JOIN vsrc_term_relationships AS tt1 ON (vsrc_posts.ID = tt1.object_id) LEFT JOIN vsrc_term_relationships AS tt2 ON (vsrc_posts.ID = tt2.object_id) WHERE 1=1 AND ( 
vsrc_term_relationships.term_taxonomy_id IN (351)
AND
tt1.term_taxonomy_id IN (274)
AND
tt2.term_taxonomy_id IN (348)
) AND vsrc_posts.post_type = 'product' AND ((vsrc_posts.post_status = 'publish')) GROUP BY vsrc_posts.ID ORDER BY vsrc_posts.post_date DESC

Array
(
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => pa_timing
[field] => slug
[terms] => Array
(
[0] => day
)

)

[1] => Array
(
[taxonomy] => pa_size
[field] => slug
[terms] => Array
(
[0] => s
)

)

)

[post_type] => product
[post_status] => publish
[posts_per_page] => -1
[product_cat] => pads
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)

[category__not_in] => Array
(
)

[category__and] => Array
(
)

[post__in] => Array
(
)

[post__not_in] => Array
(
)

[post_name__in] => Array
(
)

[tag__in] => Array
(
)

[tag__not_in] => Array
(
)

[tag__and] => Array
(
)

[tag_slug__in] => Array
(
)

[tag_slug__and] => Array
(
)

[post_parent__in] => Array
(
)

[post_parent__not_in] => Array
(
)

[author__in] => Array
(
)

[author__not_in] => Array
(
)

[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[taxonomy] => pa_timing
[term] => day
[order] => DESC
)


Which I expect WP_Query to produce. the problem is that WP_query is not producing for the dynamic query. Is there something I am missing



$dayArg = array(
'tax_query' => array(
array(
'taxonomy' => 'pa_timing',
'field' => 'slug',
'terms' => array( 'day' )
),
array(
'taxonomy' => 'pa_size',
'field' => 'slug',
'terms' => array( 's' )
)
),
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => - 1,
'product_cat' => 'pads'
)


This is argument I am passing to WP_Query one generating dynamically and one hardcoding it.







php wordpress woocommerce






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 17:22







Mustanish Altamash

















asked Mar 26 at 21:34









Mustanish AltamashMustanish Altamash

661 silver badge6 bronze badges




661 silver badge6 bronze badges















  • @LoicTheAztec I have updated my question with related WP_Query arguments

    – Mustanish Altamash
    Mar 27 at 10:22












  • I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

    – Mustanish Altamash
    Mar 27 at 17:24

















  • @LoicTheAztec I have updated my question with related WP_Query arguments

    – Mustanish Altamash
    Mar 27 at 10:22












  • I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

    – Mustanish Altamash
    Mar 27 at 17:24
















@LoicTheAztec I have updated my question with related WP_Query arguments

– Mustanish Altamash
Mar 27 at 10:22






@LoicTheAztec I have updated my question with related WP_Query arguments

– Mustanish Altamash
Mar 27 at 10:22














I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

– Mustanish Altamash
Mar 27 at 17:24





I have updated my answer I am using.push() function to generate tax_query hope I made my question clear

– Mustanish Altamash
Mar 27 at 17:24












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366546%2fusing-dynamic-multiple-attributes-with-wp-query%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366546%2fusing-dynamic-multiple-attributes-with-wp-query%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현