Custom Backend data for map to JSON file?

I want to create a map in the frontend with data that is populated with Point of interests. I want to manage the POI data in the backend but need a generated JSON file from that backend data that talks with the JavaScript in the frontend.

If I wanted to implement it manually, how would I do that?

Topic wp-localize-script google-maps map json Wordpress

Category Web


Use the JSON REST API - http://v2.wp-api.org - It lives as a plugin now but will eventually be part of WP Core - https://wordpress.org/plugins/rest-api/

To manually output JSON, use a combination of wp-ajax to handle requests and wp_json_encode() / wp_send_json_success for simple PHP Objects and Arrays. See https://codex.wordpress.org/AJAX_in_Plugins

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.