Hi Luo,
thank you for helping with the mask script previously.
i recently discovered much logical way to filter. that is using predefined value. using this i no need to worry about the confusion that created by mobile. Pls dont ask me why i didnt think of that earlier ive no answer for you. i just discover this today.
Lets drop the mask script now. i think i can live with drop down for now. on this subject could you advice me on how to achieve the below.? hope its same ticket as its within subject case. Let me know if you need me to open new ticket point me the numbers.
1. value for "<" or ">" how do i enter that ? example > 2,000 ,000
2. after removing all prev scripts, i can't filter with value of select 2,000 ,000 the url is pointing to ' property-price_min=2%2C000%2C000' meaning the ',' is not removed.
i hope this should close the issue that ive been scratching for weeks .
hi. luo.
update
no.2 - i managed , thanks,
Dear C6410,
For Q1, what kind of input field do you need? A select dropdown field with two options "<" and ">"?
And after user choose one of the option, pass the URL parameter to the view, you will need to setup custom codes to apply the change to the query:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
HI Luo.
its a select drop down field for ' >" value.
wpv-filter-query, - do i target the field OR the " >" event ?
any sample code that i can refer to ?
thanks
Q1) wpv-filter-query, - do i target the field OR the " >" event ?
You don't need to setup a custom post field for it, you can follow our document to setup a shortcode [wpv-control-postmeta] to output a dropdown menu with option ">" and "<"
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-postmeta
Q2) There isn't such a existed demo codes for it, if you still need assistance for it, please provide a test site with same problem, I can setup a demo for you.
HI Luo. pls login and setup the demo. the user login has been activated. thanks
pls use snippets plugins . thanks.
As your request, I have setup a demo in your website:
1) Create a view to list "Landed Houses" posts, and output the select dropdown field with shortcode:
<label>[wpml-string context="wpv-views"]Sales Price[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-property-price-sale" type="select" source="custom" url_param="wpv-property-price-gs" values="bigger,less" display_values=">, <"]
[wpv-control-postmeta field="wpcf-property-price-sale" type="textfield" url_param="wpv-property-price-sale"]
filter with:
Select items with field:
Sales Price is a number greater than or equal URL_PARAM(wpv-property-price-sale)
enlace oculto
2) Add below PHP codes
add_filter( 'wpv_filter_query', 'option_values_func', 10, 3 );
function option_values_func( $query_args, $view_settings, $view_id ) {
if ( $view_id == 3144 ) {
if(isset($_GET['wpv-property-price-gs']) && $_GET['wpv-property-price-gs'] != "less"){
return $query_args;
}
if(isset($query_args['meta_query'])){
foreach($query_args['meta_query'] as $key => $value){
if($value['key'] == 'wpcf-property-price-sale'){
$query_args['meta_query'][$key]['compare'] = '<=';
}
}
}
}
return $query_args;
}
enlace oculto
3) Test above view in front-end:
enlace oculto
It is only an example, you will need to customize it according to your website settings.