Forums › Forums › Search & Filter Pro › Search by dropdown dropdown S&F 1.4->2.1 migration problem
Tagged: post meta query
- This topic has 4 replies, 3 voices, and was last updated 9 years, 8 months ago by
Ross.
-
Anonymous(Private) April 29, 2016 at 12:11 pm #44346
Hello,
I have problem with mgration from S&F 1.4 to 2.1
I need two dropdowns based on post_meta – ACF date: YYYYMMDD.
There must be only eyars, means options: 2016 2015… 2006 ‘2005 and prior’
In S&F 1.4 I managed tosimply hack ‘class-search-filter-get-results.php’ using something like this:
…
else if($meta_field[‘meta_type’]==”choice”)
{
if ($key == ‘news_date’ || $key == ‘press_date’) {
if (intval($_GET[SF_META_PRE.$key]) == 2005) {
$minval = 19950000;
$maxval = 20051232;
} else {
$minval = intval($_GET[SF_META_PRE.$key])*10000;
$maxval = (intval($_GET[SF_META_PRE.$key])+1)*10000;
}
$meta_query =
array(
‘key’ => $key,
‘value’ => array( $minval, $maxval ),
‘compare’ => ‘BETWEEN’,
“type” => “NUMERIC”
);
} else {
….
Version 2.1.2 seems to be completely rebuilt and made much more complicated. Where is the place in S&F 2.1.2 to place such improvement? Or maybe this time there are more such places?
I’ve tried e.g. in class Search_Filter_Query but I failed.
RegardsTrevor(Private) April 29, 2016 at 12:46 pm #44362Ross, the developer, is traveling for this long holiday weekend and will not be back until Tuesday.
One of the feature requests for a future version is to have year dropdowns for date fields, but this is not possible at this time. You are correct in identifying that the plugin has been completely re-written for V2.x. I do not know where or even if you can make such a change.
Ross Moderator(Private) May 12, 2016 at 9:03 pm #45426Hi Adam
Unfortunately modifying the plugin files is not directly supported by us, and is prone to this kind of error cropping up when updating.
As of 2.x, S&F has completely rewritten the way it handles it own queries.
Results, and terms, are cached in the DB, S&F then queries the cache, rather than WP for the results – so they remain fast.
This means the modification above is no longer possible – as we just don’t query meta data like that anymore.
I have been considering adding in a year dropdown field, I’ll give it another thought and see if its easy (for me) to implement.
In the meantime the best you can do is use some of our filters, but thinking about it, I’m not sure you will be able to do the above…
What you might want to look at is edit query args:
Its a bit like
pre_get_postsfor S&F, and then directly below that –filter_input_object:This will allow you to modify the data that used for creating any field in S&F.
If you want I can send you the previous version if you need to roll back, while I figure out if its feasible to add this functionality to S&F sooner rather than later.
Thanks
-
AuthorPosts