Forums › Forums › Search & Filter Pro › Outputting filtered results question, how?
- This topic has 8 replies, 2 voices, and was last updated 4 years, 4 months ago by Trevor.
-
Anonymous(Private) July 15, 2020 at 10:25 am #252876
This is the result of the GET
Array ( [_sfm_condition] => Used [_sfm_fuel] => Diesel [_sfm_loa_feet] => 0 100 [_sfm_price] => 0 150000 )This is the stringvars after converting the between value (ignore -)
Used – Diesel – 0,100 – 0,150000This is the result of the args
Array ( [meta_query] => Array ( [relation] => AND [0] => Array ( [key] => condition [value] => Used [compare] => = ) [1] => Array ( [key] => fuel [value] => Diesel [compare] => = ) [2] => Array ( [key] => loa_feet [value] => Array ( [0] => 0,100 ) [compare] => BETWEEN ) [3] => Array ( [key] => price [value] => Array ( [0] => 0,150000 ) [compare] => BETWEEN ) ) )this is the args construct
$args = array(
‘meta_query’ => array(
// ‘post_type’ => ‘post’,
// ‘category’ => 1165,
‘relation’ => ‘AND’,
array(
‘key’ => ‘condition’,
‘value’ => $condition,
‘compare’ => ‘=’
),
array(
‘key’ => ‘fuel’,
‘value’ => $fuel,
‘compare’ => ‘=’
),
array(
‘key’ => ‘loa_feet’,
‘value’ => array($nloa),
‘compare’ => ‘BETWEEN’,
),
array(
‘key’ => ‘price’,
‘value’ => array($nprice),
‘compare’ => ‘BETWEEN’,
),
// ‘key’ => ‘price’,
// ‘orderby’ => ‘meta_value_num’,
// ‘order’ => ‘DESC’
)
);
but even though in the search terms I am effectively asking for ‘give me everything’ (all test data is used and diesel currently)$custom_posts = get_posts($args);
returns
Array()I have used DRY in that I am re-using the default layout list code as in
foreach($custom_posts as $post) : setup_postdata($post);
and in there I am using ACF as in the_field(‘condition’) for data outputBUT even sending the form result to a different page it looks like
$custom_posts = get_posts($args); isn’t working?Hope you can shed some light on what is going on here
Trevor(Private) July 15, 2020 at 10:59 am #252879Hi
I am not too sure what you are asking me. Our plugin does not use wp_query to fetch posts, other than to process the form filters, work out which Post IDs are needed, and then it asks for those posts using a simplified wp_query that has
posts__in
as its argument (a long string of the matching Post IDs). We do not use an array of arguments. -
AuthorPosts