Find Jobs
Hire Freelancers

Create efficient WordPress meta query

£10-40 GBP

Completed
Posted over 8 years ago

£10-40 GBP

Paid on delivery
I'm working with WordPress with custom fields and trying to convert a query which was initially written for pjjtextbase (textfile database) to search a csv file for matching properties for rent/sale. The code works well but is quite inefficient. The code from the original progammer is /***** These values needed for select box *****/ $locations = ptb_listUnique($info, 'Property_Location'); $property_type = ptb_listUnique($info, 'Property_Type'); $property_buy_rent = ptb_listUnique($info, 'Buy_Rent'); //check property $query = Array(); if(!empty($_GET['location'])) { $query[] = "'Property_Location' == '".$_GET['location']."'"; } if(!empty($_GET['type'])) { $query[] = "'Property_Type' == '".$_GET['type']."'"; } if(!empty($_GET['buyrent'])) { $query[] = "'Buy_Rent' == '".$_GET['buyrent']."'"; } //check price if(empty($_GET['buyrent']) || $_GET['buyrent']=="Buy"){ if(!empty($_GET["min_val_buy"]) && is_numeric($_GET["min_val_buy"])){ $min_val_buy = $_GET["min_val_buy"]; } if(!empty($_GET["max_val_buy"]) && is_numeric($_GET["max_val_buy"])){ $max_val_buy = $_GET["max_val_buy"]; } $min_val_buy = min($_GET["min_val_buy"], $_GET["max_val_buy"]); $max_val_buy = max($_GET["min_val_buy"], $_GET["max_val_buy"]); $query[] = "'Price_Rent' >= '".$min_val_buy."'"; $query[] = "'Price_Rent' <= '".$max_val_buy."'"; }else{ if(!empty($_GET["min_val_rent"]) && is_numeric($_GET["min_val_rent"])){ $min_val = $_GET["min_val_rent"]; } if(!empty($_GET["max_val_rent"]) && is_numeric($_GET["max_val_rent"])){ $max_val = $_GET["max_val_rent"]; } $min_val_rent = min($_GET["min_val_rent"], $_GET["max_val_rent"]); $max_val_rent = max($_GET["min_val_rent"], $_GET["max_val_rent"]); $query[] = "'Price_Rent' >= '".$min_val_rent."'"; $query[] = "'Price_Rent' <= '".$max_val_rent."'"; } //check bedrooms if(!empty($_GET["room_no_min"]) && is_numeric($_GET["room_no_min"])){ $room_min_val = $_GET["room_no_min"]; } if(!empty($_GET["room_no_max"]) && is_numeric($_GET["room_no_max"])){ $room_max_val = $_GET["room_no_max"]; } $room_min_val = min($_GET["room_no_min"], $_GET["room_no_max"]); $room_max_val = max($_GET["room_no_min"], $_GET["room_no_max"]); $query[] = "'No_Bedrooms' >= '".$room_min_val."'"; $query[] = "'No_Bedrooms' <= '".$room_max_val."'"; //Now build the query to search $query = implode(' AND ', $query); I would like this to be converted into a WordPress meta array that fits into this code function propertysearch () { $location = preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['location']); $type = preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['type']); $buyrent = preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['buyrent']); $min_val =preg_replace('/[^0-9]/', '', $_GET['min_val']); $room_no_min = preg_replace('/[^0-9]/', '', $_GET['room_no_min']); // This replaces characters in the input string if need be for security reasons META QUERY GOES HERE AND RESULTS = $RESULTS. if(($results == 0) || ($results == false) || ($results == NULL)) : echo '<p>Sorry, there seems to be no results for your request.</p>'; $results = NULL; return $results; else : return $results; endif; } // End of my search
Project ID: 9133750

About the project

12 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi ) We are ready to discuss your project. Not the time-wasters ) Please, let us know the details of your project if you will be interested in us! Thank you, Alscon team )
£40 GBP in 1 day
5.0 (73 reviews)
6.9
6.9
12 freelancers are bidding on average £38 GBP for this job
User Avatar
I am willing to work with you I am not saying that i am the best but my coding skills show you that i em the best i am highly interested in this job. Skills: Laravel 5 PHP/MYSQL Word Press Code Igniter JS/Jquery HTML/CSS Waiting for your response. Thanks Regards : Muhammad Jawad
£105 GBP in 1 day
4.9 (224 reviews)
7.5
7.5
User Avatar
Предложение еще не подано
£32 GBP in 1 day
4.9 (444 reviews)
7.7
7.7
User Avatar
I can do it for you, I've experience 5 years with wordpress , new + custom PLG , themes and more... Now, I believe I can do it good for you! Would happy if work with you !
£37 GBP in 1 day
4.9 (74 reviews)
6.6
6.6
User Avatar
We have solution for you and we can link these query in WordPress using get_post_meta()function we need to write function for this. Let us have words on this.
£33 GBP in 2 days
0.0 (1 review)
0.0
0.0

About the client

Flag of UNITED KINGDOM
London, United Kingdom
5.0
31
Payment method verified
Member since Sep 3, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.