Skip Navigation

[Resolved] Empty filter value doesn’t paginate after page 1

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom search View with paginated results. There is a select field filter that has 3 options. If I direct Users to the search View with no select field filter applied in the URL, the results are correct. However, if I paginate to the second page or change filters, the select field no longer respects the blank URL parameter and the first option is applied.

Solution: The best solution here would be to add a default_label attribute to the select field filter shortcode.

[wpv-control-postmeta field="sale-status" default_label=" "]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-postmeta

This support ticket is created 5 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 5 years ago.

Assisted by: Christian Cox.

Author
Posts
#1377271

From the home page of hidden link, there is a picture link with the word "Snow" on it.
If you examine the URL when hovering or clicking on this, you can see that the querystring parameter "wpv-wpcf-sale-status=" has no value, and further along, "wpv-weather=snow" is set.

If you clicked on the link, you will have been taken to this URL:

hidden link

You will now see Page 1 of all the Snow pictures (which is correct), but if you click on to Page 2, there is no output, and you can see that the wpv-wpcf-sale-status has now defaulted to "1" (which means For Sale) in the querystring generated by the paging links.

Staying on this page, if you hover over Search in the menu, you can see Availability is the first drop-down select field, which has 3 choices: For Sale, Sold, Not for Sale.

With the manually constructed link from the home page, I am effectively trying to allow for nothing being selected, so that all Snow pictures - whether For Sale, Sold or Not for Sale - are returned.

As you can see, this works for Page 1, but then it goes wrong in the pagination, because it has reverted from "get me anything regardless of availability" to "For Sale", and there is only one page of output for "For Sale" items.

I hope you can suggest a way to make this work as intended.

Thank you in anticipation.

Steve

#1377305
Screen Shot 2019-11-06 at 11.04.17 AM.png

Hi, I think the most practical solution here is to add a blank default option to the filter select field. This will prevent the first option "For sale" from being selected during pagination. Please edit this View and find the shortcode for this filter in the Search and Pagination panel. If you cannot see the Search and Pagination panel, scroll to the top right corner and click "Screen Options". You can activate the panel here. You will find a wpv-control-postmeta shortcode that corresponds to this filter. Please add the default_label option to the shortcode like this:

[wpv-control-postmeta field="sale-status" default_label=" "]

You can use a blank space, or some descriptive text like "All availability" instead. This will add one extra option in the Availability select filter, which represents all availability options. Try this and let me know if the problem is not resolved.

#1377363

Hi Christian,

Yes, excellent. That works thank you!

There is a "but" though unfortunately. The Search form was intended to default to "For Sale" items, but now it defaults to "All Availability". Is there a way I can force "For Sale" to be pre-selected when the form first loads?

Thanks again for the help.

Steve

#1377367

No, the only consistent way to set a default value here is to use a URL parameter. So you could set the default value coming from the home page link, but not when landing on the page directly without a URL parameter.

#1377383

Hi Christian,

Okay, thanks. The only thing that went through my mind was if a Javascript snipped with the appropriate logic could flip it in certain situations, but I can't think how that could be made to work without possibly interfering with intended user input.

If that thought doesn't inspire a solution from you feel free to close this ticket, and thank you very much for your speedy assistance.

Best wishes,

Steve

#1377387

Right it would not easily be possible to determine whether the User actively selected the default option, or passively did not select any option. I'll mark this one resolved per your suggestion.