Skip Navigation

[Resolved] Search best SQL statement to retrieve map post

This support ticket is created 4 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by fredericP 4 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1596353

Tell us what you are trying to do?

I need to make a SQL statement to retrieve for each "Video" CPT the address field and especially the GEOMETRY POINT related to each address field in the CPT.

I've seen that the wp_toolset_maps_address_cache stored the point and that it has this address_passed as primary key but I do not know where is this PRIMARY key refered in my main related CPT.

Can you help ?

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#1596763

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to inform you that Toolset stores the Map address field as address string to postmeta table. So, if you want to get an actual address assigned to your video CTP, you need to run a normal WP_Query with post meta argument.

For example:

//later in the request
$args = array(
    'post_type'  => 'video ', //or a post type of your choosing
    'posts_per_page' => -1,
    'meta_query' => array(
        array(
            'key' => 'wpcf-address-field',
             'compare' => 'EXISTS'
        )
    )
);
$query = new WP_Query($args);   

Where:
- You need to replace wpcf-address-field with your actual address field slug.

Using above query you will get all posts where the address field value is assigned.

We do not store the GEOMETRY POINT (lat,lon) values to post meta table, so you need to query the table wp_toolset_maps_address_cache and match the address field value from postmeta with column address-passed value of wp_toolset_maps_address_cache which holds the point (lat,lon) values.

However, this may need custom programming which is beyond the scope of our support policy. You may consider hiring a pro professional using the following contractor's list: https://toolset.com/contractors/

#1597071

Thanks, I will do my self the comparison with the associated table.
Have a nice day