Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Date Filter: Who is working today
- This topic has 7 replies, 2 voices, and was last updated 1 year, 5 months ago by
Ernest Marcinko.
-
AuthorPosts
-
December 17, 2024 at 6:22 pm #52288
luxeottawaxxxcom_H55J
ParticipantPurpose: I want have a filter, preferably a button that filters only the employee available today. I would like that boutton to be a slider defaulting on “Working Today” but let the user change that slider to “All” to show all employees. If possible I would like to have another calendar based field that would show the employees working on the day specified.
What I did so far: I created a custom post type called Attendant to which I associated an advance custom field with a “Multi Dates Picker” type . Each record in the custom post type will be associated with that field and it will contain the dates that each attendant will work.
I created a loop item using the custom post type. I bought Ajax Search Pro, I created a Search Instance, to which I associated the custom post type in the search sources. I also created in the Frontend Search Settings an option for custom field.
Results: I associated the elementor post widget to the elementor setup and added the search custom code the page. A search field shows up, but as explained earlier that’s not the purpose of why I’m trying to accomplish. Is it possible to guide me towards my goal?
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
-
This topic was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
December 18, 2024 at 1:34 pm #52301Ernest Marcinko
KeymasterHi!
This may require some custom coding in my opinion – all because of the multidate picker. That is a very complex field and I’m not sure if it’s possible to simply filter based on it’s value, as it’s not a single date, but likely an array of date fields.
However, I believe it is very likely possible to create a radio button or even a checkbox type of filter to choose to show between All/Working Today values.
Can you please add temporary FTP and back-end access? I will have to take a direct look at this, as I don’t know how the multidate picker stores the values. Based on the exact setup I will try to suggest a custom code snippet, which would convert the All/Working Today checkbox/radio filter to an actual results filter in the post processing based on the user selection.
December 18, 2024 at 9:21 pm #52306luxeottawaxxxcom_H55J
ParticipantThank you. I added the temporary FTP and back-end access. A radio button is a good compromise, I was initially thinking of even hiding the filter option. Could that configuration be used without Elementor Pro? I was wondering if the combination Blocksy Pro/ Guttenberg could be an option as I am trying to get away from subscription since I will not be the owner of that website once all is done.
December 19, 2024 at 1:25 pm #52313Ernest Marcinko
KeymasterYou cannot access this content.
December 19, 2024 at 2:06 pm #52316luxeottawaxxxcom_H55J
ParticipantThank you for your quick response, I just updated the information, is it possible to let me know if it doesn’t work?
-
This reply was modified 1 year, 5 months ago by
luxeottawaxxxcom_H55J.
December 21, 2024 at 9:17 am #52329Ernest Marcinko
KeymasterThe back-end login now works perfectly, thank you! However I can’t connect via FTP, can you please check that as well?
I was able to check the date structure, I believe this should be possible via a custom code snippet. Let me know if you can check the ftp access, and I will test a possible solution.
December 21, 2024 at 3:57 pm #52331luxeottawaxxxcom_H55J
ParticipantHi, thank you. I updated the username, I think that was the issue.
December 29, 2024 at 3:58 pm #52367Ernest Marcinko
KeymasterPefrect!
I have managed to put together a fairly tiny code snippet, which seems to be working. I have placed it into the code snippet plugin you are using under the name “Ajax Search Pro – Today filter”.
I have also changed the filter to a radio button, with a yes/no option. When “Yes” is clicked, then only results matching todays date should be displayed.
For future reference, here is the custom code, it turned out to be only a few lines:
add_filter('asp_query_args', function($args){ foreach ( $args['post_meta_filter'] as $k => &$filter ) { if ( $filter['key'] !== 'days_worked' ) { continue; } if ( $filter['value'] === 'no' ) { unset($args['post_meta_filter'][$k]); } $filter['value'] = date('Y-m-d'); } return $args; }); -
This topic was modified 1 year, 5 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.