Forums › Forums › Search & Filter Pro › Query another WordPress table
Tagged: availability, date, query, table, wordpress
- This topic has 38 replies, 4 voices, and was last updated 8 years, 4 months ago by Anonymous.
-
Anonymous(Private) July 14, 2016 at 2:08 pm #51158
Hi Trevor,
Thank you for your e-mail. That line is uncommented on the live version.If you check the php files that I’ve sent you you’ll see that that line is uncommented. What you have in the 2 php files is what is live right now as I didn’t update these files since I’ve sent them to you.
Thank you for your help,
FrançoisAnonymous(Private) July 22, 2016 at 12:23 am #51869Just my two cents:
To me it looks like the query_args never get updated with the selected options (checkboxes, dropdowns) from the search form. Only options set in the S&F UI like in the “Post Meta” tab and the “Posts” tab like order, post_type are added.
These “fixed” query_args are then passed to WP_Query. The result id’s are filtered based on the GET/url filters. I might be wrong, but this is what I get from looking over the S&F code. This means you will not be able to remove your added datepicker from the query_args.
I am in the same boat, hence my interest in this topic.
What I did was the as follows:
Remove the datepicker (change “animals” to your datepicker metafield name. from the get request, this can be done in a custom plugin on the init action. In my case I have a checkbox for post_meta fields which I unset with:if(isset($_GET['_sfm_animals'])) { $_GET['my_sfm_animals'] = $_GET['_sfm_animals']; unset($_GET['_sfm_animals']); }
As you can see, I keep a reference to the field with the “my” prefix. You will need this later in order to keep the checkbox selected, or with the datepicker to have the date still set when returning results.
Now comes the ugly part. You will have to edit the plugin file
“class-search-filter-active-query.php” and add a similar entry just before:
“$this->field_values = $field_values;”if($_GET["my_sfm_animals"]) { $keys = explode("-+-", $_GET["my_sfm_animals"]); if(count($keys)) { foreach($keys as $value) { $field_values['_sfm_animals'][] = $value; } } }
Without this edit, my selected checkboxes are unchecked after returning the results (might not be necessary on ajax requests).
I hope this is of any help to you, for me this works great. I can now exclude all selected animals from the results, based on what the user selected.
Ross Moderator(Private) August 6, 2016 at 8:36 pm #53701Hey Arend
Thanks for your workaround you posted (haven’t tested it yet).
François, did that help you or still stuck?
As mentioned a few posts back, rather than figuring out an elaborate hack like this (!) I’m actually hoping to support these features to make this possible (including creating your own field)…
I’m happy to take a look at what you are doing and advise but you’re entering uncharted territory 😉 I think the real solution is just to implement this as proper features!
Best
-
AuthorPosts