Skip Navigation

[Resuelto] wpv-control-postmeta , comma separated list of option values

This support ticket is created hace 6 años, 11 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Luo Yang hace 6 años, 11 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#599488

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 .

#599693

hi. luo.

update

no.2 - i managed , thanks,

#599745

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

#599761

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

#599795

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.

#599800

HI Luo. pls login and setup the demo. the user login has been activated. thanks

pls use snippets plugins . thanks.

#600086

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.