Forums › Forums › Search & Filter Pro › Split: Does not work with Elementor Pro and Ele Custom Skin loops
- This topic has 46 replies, 3 voices, and was last updated 4 years, 6 months ago by Ross.
-
Anonymous(Private) March 13, 2020 at 2:18 am #236557
Hello Trevor, and Paul.
I can confirm that the plugin works well with Elementor Pro and Ele Custom Skin loops.
The only issue I’ve seen up until now is that pagination is displayed incorrectly the first time the page loads, then it is fixed when you click on a page number.
For example:
In a query that should’ve shown 8 pages of posts, the pagination shows links for 14 pages.
If you click on any page number between 1 and 8, the correct page loads, with the right content. Also, the pagination is fixed and will now show only numbers 1 through 8.
But, if you click on any invalid page number (9-14), the results come up empty.My question is: why is that first page showing an incorrect number of results?
If you wish to see it in action, you may visit:
https://worldyachtgroup.com/yachts-for-sale/Thanks for everything, Trevor!
Armando J.Ross Moderator(Private) March 13, 2020 at 1:15 pm #236629Hi Armando
I’ve split this into a new topic.
The issue you have is that when you do a default search (without changing anything in the search form), your range sliders are submitted at the min + max values.
I’m guessing some of your posts, don’t have values for some of those sliders, so once submitted, they dissapear from the results.
I hope that makes sense.
Thanks
Anonymous(Private) March 13, 2020 at 1:27 pm #236638Thank you for your quick response, Ross!
That does make sense. Do you know of a way where I could force the initial page load to use the valid values from the search form?In other words, I prefer it to only show results that match whatever can be searched.
In the example I gave earlier, I would prefer it if the pagination only showed pages 1 through 8.
Thanks again!
Anonymous(Private) March 16, 2020 at 3:27 am #236725I think I’ve got another way to phrase my question:
I’m running a regular WP Query to get those initial posts to show up. I could probably add the proper parameters to the query so that it matches whatever Search & Filter Pro is querying when doing a “default search”.
This is how it looks right now in the URL:
https://worldyachtgroup.com/yachts-for-sale/?_sfm_offered_at_eur=0+129000000&_sfm_length_meters=20+90&_sfm_year_built=1994+2021&_sfm_cabins=0+18Do you have a reference on how the plugin builds those queries? Or is there a hook/filter I could tap into via PHP?
Thanks again! The plugin is fantastic!
Trevor(Private) March 16, 2020 at 3:55 pm #236823Hi
Ross has asked me to take this topic over.
The problem with trying that approach (and I do not think it can be done), is that some boats will never be shown. If they fail any of those 3 filters, they disappear from the results. I am not sure this is what you want to do.
Let us assume that a boat does not have an ‘Offered At’ price, and the field is empty, like Amadea, then it will not appear at all. The same applies for the other two fields, length and year built.
This is a problem only associated with using range fields. You might be better to have secondary related search fields where choices are offered that encompass the precise values entered (where applicable):
So, a Secondary ‘Offered at’ field might look like the following options (in checkbox type filter):
Request
0-10m
10m-20m
20m +That way you avoid this problem entirely.
Trevor(Private) March 17, 2020 at 9:54 am #236883Let us say you have the ‘Offered At’ field, and so you make a second field, let us call this ‘Offered At Choices’.
So, when entering the data, the Offered At field has the real number, but you select a range choice for the Offered At Choices field.
Now, it is possible to use the WordPress save_post() function to create your own logic/code/PHP (placed in the child theme functions.php file) so that, when a boat is saved, the code looks at the saved Offered At number and uses that code to create the correct string value to save in the Offered At Choice field, including creating a default value (like ‘Request’ where no value was entered).
This isn’t simple, but it can be done. There are snippets of code that do this sort of thing on the StackExchange web site.
Trevor(Private) March 17, 2020 at 10:03 am #236891I will refer this to the plugin developer, Ross, to see if there is a way to use this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
(or another he might know of)
To examine the values for a range field and compare those to the default value, and if they are at the default value, remove that part of the query. It might require that Auto Detect min and max are not set (that min and max are set manually) so that they can be known in the code.
Anonymous(Private) March 18, 2020 at 4:31 pm #237092Thank you, Trevor!
I’ve discussed it with the team and they prefer to keep the current “range slider” type feel for the filter bar. So that brings us to your second suggestion, and I’m looking forward to seeing what Ross thinks of this.If we could somehow alter the query in a way that would show all vessels when a particular range field is at the default point, that would be great.
What are your thoughts, Ross?
Thanks again!
Ross Moderator(Private) March 19, 2020 at 5:48 pm #237258Hi Armando
So I’ve been thinking a bit about this, and obvously at some stage in the future we want to improve the way all this works, from within the plugin.
Let me just say, you can’t alter the query in the way you want using
sf_edit_query_args
– this is because we actually perform our search outside of the WP_Query, and insert the results… anyway, for now I see you have only two options going forward:1) Assign a default value (lets say
0
) to all posts that don’t have a value, and make sure the range slider starts at 0. This is a lot easier to do than it may seem. You run anew WP_Query
to find all posts that don’t have this value assigned (NOT EXISTS
) – for example you can see here:
https://wordpress.stackexchange.com/questions/80303/query-all-posts-where-a-meta-key-does-not-exist
Then when you look through each results, all you do is useadd_post_meta()
to set it to0
– https://developer.wordpress.org/reference/functions/update_post_meta/2) As you mentioned at the beginning, you wanted the results on page load, to match those after a search has been performed once the default range slider values are added. You can in fact do this, by going to the
post meta
tab in your search form, and adding two conditions in, to ensure all posts are above and below a specific values.I hope that explains things a bit and gives you some viable options to work with!
Let me know if you have any follow up questions.
Thanks
-
AuthorPosts