Forums › Forums › Search & Filter Pro › Infinite scroll not working on initial load
Tagged: infinite scroll
- This topic has 24 replies, 3 voices, and was last updated 6 years, 4 months ago by Ross.
-
Ross Moderator(Private) July 6, 2018 at 2:18 pm #182076
Hi Jane
Apologies for the delay – there’s been a good few things happenening and this slipped between the cracks.
In regards to your original problem, you were setting the second hidden date field with JS, and it was not being picked up properly on load more / pagination.
Well, we have a filter that allows you to set various attributes / values of each input field, via PHP (which I think may be more reliable):
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
It actually gets a bit tricky targeting the second date field, as both the fields have the same name, so I did a little test and wrote this snippet which should work (add to functions.php):
add_filter('sf_input_object_pre', 'filter_input_object', 10, 2); global $from_to_field_count; $from_to_field_count = 0; function filter_input_object($input_object, $sfid){ //we need to target the second field with this name, $date_field_name = "_sfm_my_date_field"; if( $date_field_name === $input_object['name']){ global $from_to_field_count; $from_to_field_count++; if(2 === $from_to_field_count){ $input_object['attributes']['value'] = "29/07/2018"; } } return $input_object; }
Make sure to replace
_sfm_my_date_field
with the name of your date field.Let me know how you get on!
Thanks
-
AuthorPosts