There is something missing because this is driving me crazy at the moment.
I'm using the wp_query with the following args.
$args = array(
'post_type' => 'project',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_sf_project_budget',
'value' => '6',
//'compare' => '=',
//'type' => 'NUMERIC'
)
)
);
$search_query = new WP_Query($args);
When print_r the $search_query I can see the following:
WP_Query Object
(
[query_vars] => Array
(
[post_type] => project
[post_status] => publish
[meta_query] => Array
(
[0] => Array
(
[key] => _sf_project_budget
[value] => 6
)
)
But the "SQL" doesn't seem to change:
[request] => SELECT SQL_CALC_FOUND_ROWS wps_posts.* FROM wps_posts
WHERE 1=1 AND wps_posts.post_type = 'project'
AND (wps_posts.post_status = 'publish')
ORDER BY wps_posts.post_date DESC LIMIT 0, 10
Shouldn't this change to incorporate the meta query vars?
Can't see what I'm doing wrong or what's missing, tried different things and it brings all the posts all the time. I checked in postmeta table and I can see that the values are there.
Any pointers in the right direction?
Thank you.
_get_meta_sql
. You can check the output by hooking intoget_meta_sql
. Dump that value and see what it gives.