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.
-
Ross Moderator(Private) July 1, 2016 at 12:28 pm #49998
Hey Francois
What you are trying to do is technically not possible with S&F at the moment.
I have made good steps towards allowing this kind of functionality but its not ready yet.
The idea is that you will be able to create your own fields in the forms and wire them up any way you wish in terms of affecting the query..
**Edit – I started writing a potential workaround below, but as I got through it and checking the plugin options I realise this is not possible either. I will be looking into adding a new “compare mode” which facilitates the exclude of dates – which does not yet exist but I can’t see it being too hard to add.
Anyway.. leaving this info here as it will become relevant again once I add in the required functionality..
However for now this is not yet possible so the way I would approach the above is to save the unavailable dates as post meta – and I would automate this…
So my approach would be:
1) hook into save_posts
2) Whenever an event is saved (check the post type etc), also save those unavailable dates as post meta using update_post_meta – make sure the date is saved in YYYYMMDD format in the post meta (you might have to do some date formatting using the PHP date function)
3) Then in S&F, you can add a post meta field, set it to date, choose the correct start/end meta keys and then change the “compare mode” to exclude (* this is the compare mode that needs adding to the plugin and is not yet available)Hope that explains things a bit, I will be looking at timelines to add this in and get back to you.
Thanks
Anonymous(Private) July 11, 2016 at 9:33 am #50777Hello Ross,
Thank you for your answer.
I’ve managed to update the Wp posts results outputed by your plugin based on a specific hardcoded date.
What I do is the following :
– as soon as your plugin get the results based on the S&F form, I get the wp posts list,
– then based on the hardcoded date I check for each of the shows outputed by your plugin if it’s available for that date or not,
– then I only keep and display the shows which are available for that date.Would it be possible for you to explain me :
– how to create a new datepicker field (hardcoded somewhere in your plugin I guess) to display it in a specific Search & filter form,
– will that new field automatically appear in the url (get method) as the others fields ? like : date=20160711 .As soon as I’ll be able to add that field and get it from the url I’ll be done! Soo cool! Thank you 🙂
Thank you for your help,
FrançoisTrevor(Private) July 12, 2016 at 10:48 am #50883Hi François
I am wondering whether you could create a fake array of dates and get S&F to use this as a date field which would then use the datepicker?
Some time ago another user figured how to do this (in their case doing a lookup on an ACF field), see here:
https://support.searchandfilter.com/forums/topic/acf-labels-not-being-picked-up/
But maybe the principle could work for you? A stab in the dark by me.
Anonymous(Private) July 12, 2016 at 10:54 am #50884Hi Trevor,
I’m using ACF on our site so it sounds like a good idea.
I’ve just checked and it seems that they provide datepicker as well.Then I can add that field with the form editor and update the query like explained before.
That sounds good! I’ll try it soon and I’ll come back to you.
Thank you for your help,
FrançoisTrevor(Private) July 12, 2016 at 11:15 am #50886You can remove it from the query. See the filters here:
http://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Filters
Anonymous(Private) July 12, 2016 at 2:20 pm #50910Hi Trevor,
I’ve quickly added the filter function in my functions.php file and the function is well fired.
My concern is that the print_r($args) array is empty and that the url parameters are not displayed in the url anymore. Is it normal ?
Shouldn’t it contain the args of the original query ? Then I could update them and return them ?
How can I catch the args every time the user modify its request ?Thank you!
-
AuthorPosts