Skip Navigation

[Resolved] Filter option values with commas

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

Problem: I am providing custom display_values in a search View filter shortcode. I would like to use commas in one of these values, but the system interprets the comma as another option for the filter. How can I use a comma in the option text?

Solution: Use the HTML entity for comma:

[wpv-control-postmeta field="wpcf-price-range" type="select" source="custom" url_param="wpv-wpcf-price-range" values="3,2,1" display_values="5,000,400,300" default_label="All"]

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

This support ticket is created 5 years, 1 month 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.

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 2 replies, has 2 voices.

Last updated by josephC-5 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1374159

Hi there,

I had a question about the display_values attribute for the [wpv-control-postmeta] shortcode. Here's a snippet of code from my site:

[wpv-control-postmeta field="wpcf-price-range" type="select" source="custom" url_param="wpv-wpcf-price-range" values="3,2,1" display_values="500,400,300" default_label="All"]

Above the value of display_values is "500,400,300." My question is, is it possible for the comma-separated list assigned to display_values to contain a comma? My client is dealing with money, and I might need the values in the thousands of dollars, but the following won't work: "3,000,2,000,1,000". Is there a way to "escape" commas when they are set as an attribute value?

Thanks!

Saul

#1374239

You can try using the & #44; entity (without a space) like this:

[wpv-control-postmeta field="wpcf-price-range" type="select" source="custom" url_param="wpv-wpcf-price-range" values="3,2,1" display_values="5,000,400,300" default_label="All"]
#1374263

That did the trick.

Thanks, Christian!

Saul