SportsPress icon indicating copy to clipboard operation
SportsPress copied to clipboard

How to add to api sp_latitude and sp_longitude?

Open kruzikruz opened this issue 1 year ago • 1 comments

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

kruzikruz avatar Aug 05 '23 15:08 kruzikruz

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

robaduncan avatar Dec 22 '23 15:12 robaduncan