Skip Navigation

[Resolved] Create Data Range Search for Dropdown

This support ticket is created 5 years, 9 months 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
- 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)

This topic contains 13 replies, has 3 voices.

Last updated by ericW-8 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1220484
acreage_filter_params.png
acreage_assistance_request.png
acreage_assist_2.png

Tell us what you are trying to do?
We offer property in ranges:
Less than 50 Acres
50-99
100-249
250-499
500+

I need the ACREAGE dropdown to work with my search which is already working to select
Counties
or
Sales Price

I do not want to use a Min-Max form group unless you can tell me how to create a RANGE of acreage in the min-max boxes. When I do that now, it populates my actual property acreages and doesn't look professional.

***This is a test site with only a few properties. One of the issues I'm also having is that the Counties search does not return all of the results. NOTE: McLennan County. I have 2 properties, and only one will show up in the COUNTY search, but when I put in the price it will show up.***

Is there any documentation that you are following?

I used this post: https://toolset.com/forums/topic/add-price-range-filters-to-views-archive/
to solve my pricing range dropdown problem.

I have the same issue for my acreage issue and can't seem to figure out how to make it work with my total acreage dropdown.
I tried to adjust the coding, but don't have the experience to make it work.

I've looked at several different posts but couldn't find one to answer my challenge.

Additionally, my filters tell me I must use "and" rather than "or". I'm not sure why this error is occurring.

Is there a similar example that we can see?
Not that I'm aware

What is the link to your site?
hidden link

#1220646

Hello,

It is a custom PHP codes problem, please provide a test site with the same problem, fill below private detail box with your website credentials, also point out where I can edit your PHP codes, I need to test and debug it in a live website. thanks

#1221742

I need an email address to add you as a user.

#1222129

Here is my email: luo.y@onthegosystems.com

Please also point out where I can edit your PHP codes,
Thanks

#1222837

Thanks for the details, I can login into your website, when I try to edit theme file functions.php, I get these error:
Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.

Please provide the FTP access in below private message box

#1223657

The FTP password/username is not valid, I get this error:
Response: 530 Login authentication failed

Please check it.

#1224276

Thanks for the details, the new FTP access is valid, but after login with the new FTP access, I see only an empty folder, would you check it?

#1224480
file_screenshot.png

I believe you looked at the wrong folder. There is a "testsite" that is not empty. The one below it
"legacylands.testsite.com" is empty.
Here again is a screenshot of the file path.

#1224803
ftp.JPG

I have tried the FTP access you provided in post:
https://toolset.com/forums/topic/create-data-range-search-for-dropdown/#post-1223978

It is not valid, I see an empty folder, see screenshot hidden link

Please check it, make sure it is valid, thanks

#1225556

The FTP access is not valid, I see same empty folder.

So I have export your website database into my localhost, test and debug the PHP codes, please try these:
Edit your theme file "functions.php", find those lines:

add_filter('wpv_filter_query', 'search_between_acreage_func', 90, 3);
function search_between_acreage_func($query, $setting, $view_id) {
...
}

Replace them as below:

add_filter('wpv_filter_query', 'search_between_acreage_func', 90, 3);
function search_between_acreage_func($query, $setting, $view_id) {
    if($view_id == 1897){ // specific Views ID
		foreach((array)$query['meta_query'] as $k=>$v){
			if(isset($v['key']) && $v['key']=='wpcf-total-acreage'){ // custom field total-acreage
 				if( isset($_GET['wpv-wpcf-total-acreage']) && !empty($_GET['wpv-wpcf-total-acreage'])){ // with URL parameter wpv-wpcf-total-acreage
					$query['meta_query'][$k]['value'] = str_replace("-",",",$_GET['wpv-wpcf-total-acreage']); // apply the range filter
				}else{ // without URL parameter wpv-wpcf-total-acreage
					unset($query['meta_query'][$k]); // remove the range filter
				} 
				break;
			}
		}
	}
    return $query;
}

And test again, it works fine in my localhost.

#1225906

Thank you. It works beautifully
EXCEPT
at the 500+ acre range, it pulls in all the properties, rather than giving a "no results found" message.
Thoughts?

#1226331

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Luo has a day off today. He will get in touch with you as soon as he will get back to work on Monday.

Well - I selected the option 500+ acre range from the drop-down "Acreage" and its displaying the "no results found" message. Please check with the following link:
hidden link

#1226926

Yes, Minesh is right, you can setup the last option's value as 50-500000, then it should be able to work.

#1227442

My issue is resolved now. Thank you!

I have another challenge with hiding the search results until the user submits. I will open a new support ticket.