ThemeBoy / SportsPress

An open source league statistics plugin for WordPress created by ThemeBoy.
Other
155 stars 98 forks source link

How to add to api sp_latitude and sp_longitude? #447

Open kruzikruz opened 1 year ago

kruzikruz commented 1 year ago

How to add sp_latitude and sp_longitude so that the data is visible in the api?

robaduncan commented 11 months ago

Try following this advice I received from Themeboy support:

I've created code that adds the address information into the REST API response you are using. Here's the code snippet:

<?php
/**
* Add address information to the REST API route `wp-json/sportspress/v2/venues`.
*/
add_filter('rest_prepare_sp_venue', function ($data, $term, $request) {
$data->data['custom_meta'] = get_option("taxonomy_$term->term_id");
return $data;
}, 10, 3);

I recommend you inject this code into your website using the Code Snippets plugin. But, that's up to you.

Thanks, Nabil

I tried this and it worked for me