The forums are closed and will be removed when we launch our new site.
Looking for support? You can access the support system via your account.
Forums › Forums › Search & Filter Pro › ACF custom fields are shown correctly as filter but aren't filtering the results
Tagged: acf, ajax, custom fields, results, url
- This topic has 23 replies, 2 voices, and was last updated 6 years, 1 month ago by Doron Wolf.
-
Trevor Moderator(Private) August 20, 2018 at 11:57 am #185956This reply has been marked as private.Doron Wolf(Private) August 21, 2018 at 12:07 pm #186067
hi Trevor
sorry for the delay
seems like my client is happy using taxonomies more than custom fields so for now i have to leave things they are
Unfortunately this means we wont have the possibility to check the misbehavior of the from with custom fields but since it’s working now and the client is happy i Guess we should move onBut now we have a different problem – one of the filters is about to be populated with many new terms (more than 30) which will probably make the search form look ridiculously long because the client insists on using only checkboxes
is there a way to show only the first 5 and than hide the others under ‘show more’ link?
should I open a new thread for this?Trevor Moderator(Private) August 21, 2018 at 12:35 pm #186069Hi
There is not an option to do that within the plugin, so you would need to install and use (or code for yourself) a javascript solution. Whilst I don’t have any examples, I have seen websites that do this. The best idea is to use the header to collapse or hide the list.
Trevor Moderator(Private) August 21, 2018 at 1:27 pm #186097You need to run your code again. Either duplicate in the snippet below, or make it a function, call it on document load and also in the snippet below:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); // call your function(s) here }); }(jQuery));</script>
Doron Wolf(Private) August 21, 2018 at 1:43 pm #186099already done that
my code is(function($) { // $ Works! You can test it with next line if you like $('#search-filter-form-123 > ul > li > h4').click(function() { $(this).parent().find('ul').toggle(); }); })( jQuery );
and in the beginning the function will work only once and stop working at all after the ajax refreshes the results
so i did as you suggested and now you can click to collapse again even after the results are refreshed
but its eems that there is a built in search and filter css:
.searchandfilter ul {display: block; …} that might be kicking in every time the results are refreshed
is there a way to make this css line “run only once” ? and not every time the page refreshes the results?Trevor Moderator(Private) August 21, 2018 at 1:51 pm #186102The CSS is loaded only once. If you need to change that, make you own css like this:
#search-filter-form-123.searchandfilter ul {display: block; …}
Doron Wolf(Private) August 21, 2018 at 2:11 pm #186108if the css is loaded only once than i’m not sure what’s causing the filter titles to expand each time the results are refreshed
if you inspect my page and look at chrome developer console you will see that every time the results are refreshed, the whole form is also refreshed (both result container and form are seem to be refreshed) which make the css styling to apply again (and so display:none become display: block e.g resets the toggle status)
Doron Wolf(Private) August 21, 2018 at 2:19 pm #186110UPDATE:
o.k.. it seems that if i disable the ‘auto count’ and the ‘Update the Search Form on user interaction’ in the form settings than the problem go away..but than the toggle will stop working randomly (some time it will work and some other times it wont)Trevor Moderator(Private) August 21, 2018 at 3:28 pm #186128The code I gave you works when the form submits. To also catch when the form performs an Ajax Auto Count, the code looks like this:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxformfinish", ".searchandfilter", function(){ console.log("ajax complete"); // call your function(s) here }); }(jQuery));</script>
Notice the use of ajaxformfinish instead of ajaxfinish.
-
AuthorPosts
The topic ‘ACF custom fields are shown correctly as filter but aren't filtering the results’ is closed to new replies.