ThemeBoy/SportsPress

How to add to api sp_latitude and sp_longitude?

Opened this issue · 1 comments

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

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