
WordPress WPDB SQL Help
- or -
Post a project like this3077
$$
- Posted:
- Proposals: 4
- Remote
- #1340538
- Awarded
Description
Experience Level: Intermediate
General information for the website: Real Estate Website
Kind of development: Customization of existing website
Description of requirements/features: Im using a customised version of the Realsite WordPress theme by Aviators (http://preview.byaviators.com/theme/realsite/).
There are three areas that I need help with, all SQL related.
I've updated the search form (and search results) to pass through a longitude and latitude reference. Im then using WP_Geo_Query to sort the results based on distance from the searched location.
Ref: https://gist.github.com/jackabox/a9c4543fd7001a6f387df7166a0cf491
1> The problem I have is that sometimes the results are fine, other times the properties are duplicated many, many times.
E.g. Lets say I search for "Location A"
Sometimes the results will appear as: Property B, Property C, Property D etc. Which is fine.
Sometimes the results will appear as: Property B, Property B, Property B, Property C, Property C, Property C, Property D, Property D, Property D etc.
2> It would also be useful (once this duplication has been fixed) to show the distance (from the searched location) next to each result
E.g Property B (1 mile), Property C ( 3 miles), Property D (8 miles) etc.
3> Finally, I've built a "statistics page". This page pulls various bits of info about the properties listed on the site. Be it, for example, the total number of properties listed, the total number of views each property has received, the average views per property etc.
https://cl.ly/132r3J3t3W13
I've built this using a number of WP_query statements, PHP loops and some simple maths. Im sure there must be a more elegant/efficient way to do this using SQL.
Im not suggesting that all items on the page need to be handled via SQL, but I suspect some of them could be and it would be better than what Im currently doing.
The Logic for the stats page is as follows: https://cl.ly/0c0E2l0s1a2J
1> Total Number of published properties ("property" custom post type)
2> Total Views. For each property, get the number of views from DB (i already have the function/SQL statement to do this)
3> Point 2 / Point 1
4> Total Enquiries. For each property, get the value of a custom meta field and add them all together.
5> Point 4 / Point 1
6> Number properties let within past 30 days. When a property is marked as Let, it's added to a "let" term and a custom field is updated to include the time at which this changed occurred. Look through all published properties with the Let term. Is the value of the meta field within the past 30 days.
7> Average time to let. For each property, what is it's published date? If it's let, what date is in the custom field? If it's not let, what is today's date? For let properties, take the value of the published date away from the value of the custom field. For unlet property, take the value of published date away from today's date. Add this time together. Divide by Point 1.
8> For each location, get the location name.
9> For each property within this location (term taxonomy) get the total views. As per Point 2. Add them all together.
10> Point 9/Point 8
11> For each property within this location (term taxonomy) get the value of a custom meta field. Add them all together.
12> For each location, Point 11 divided by number of properties in that location
13> For each location, as Point 6
14> For each location, as Point 7
15> For each property within each location, get the value of a custom field. Add them all together, divide by number of properties in that location.
I can provide access to a development site which contains the code (for the above tasks) already in place.
Extra services needed: Customization
Specific technologies required: wpdb sql
Extra notes:
Kind of development: Customization of existing website
Description of requirements/features: Im using a customised version of the Realsite WordPress theme by Aviators (http://preview.byaviators.com/theme/realsite/).
There are three areas that I need help with, all SQL related.
I've updated the search form (and search results) to pass through a longitude and latitude reference. Im then using WP_Geo_Query to sort the results based on distance from the searched location.
Ref: https://gist.github.com/jackabox/a9c4543fd7001a6f387df7166a0cf491
1> The problem I have is that sometimes the results are fine, other times the properties are duplicated many, many times.
E.g. Lets say I search for "Location A"
Sometimes the results will appear as: Property B, Property C, Property D etc. Which is fine.
Sometimes the results will appear as: Property B, Property B, Property B, Property C, Property C, Property C, Property D, Property D, Property D etc.
2> It would also be useful (once this duplication has been fixed) to show the distance (from the searched location) next to each result
E.g Property B (1 mile), Property C ( 3 miles), Property D (8 miles) etc.
3> Finally, I've built a "statistics page". This page pulls various bits of info about the properties listed on the site. Be it, for example, the total number of properties listed, the total number of views each property has received, the average views per property etc.
https://cl.ly/132r3J3t3W13
I've built this using a number of WP_query statements, PHP loops and some simple maths. Im sure there must be a more elegant/efficient way to do this using SQL.
Im not suggesting that all items on the page need to be handled via SQL, but I suspect some of them could be and it would be better than what Im currently doing.
The Logic for the stats page is as follows: https://cl.ly/0c0E2l0s1a2J
1> Total Number of published properties ("property" custom post type)
2> Total Views. For each property, get the number of views from DB (i already have the function/SQL statement to do this)
3> Point 2 / Point 1
4> Total Enquiries. For each property, get the value of a custom meta field and add them all together.
5> Point 4 / Point 1
6> Number properties let within past 30 days. When a property is marked as Let, it's added to a "let" term and a custom field is updated to include the time at which this changed occurred. Look through all published properties with the Let term. Is the value of the meta field within the past 30 days.
7> Average time to let. For each property, what is it's published date? If it's let, what date is in the custom field? If it's not let, what is today's date? For let properties, take the value of the published date away from the value of the custom field. For unlet property, take the value of published date away from today's date. Add this time together. Divide by Point 1.
8> For each location, get the location name.
9> For each property within this location (term taxonomy) get the total views. As per Point 2. Add them all together.
10> Point 9/Point 8
11> For each property within this location (term taxonomy) get the value of a custom meta field. Add them all together.
12> For each location, Point 11 divided by number of properties in that location
13> For each location, as Point 6
14> For each location, as Point 7
15> For each property within each location, get the value of a custom field. Add them all together, divide by number of properties in that location.
I can provide access to a development site which contains the code (for the above tasks) already in place.
Extra services needed: Customization
Specific technologies required: wpdb sql
Extra notes:

Chris H.
100% (198)Projects Completed
165
Freelancers worked with
115
Projects awarded
13%
Last project
2 Dec 2024
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies