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?

  • You would likely want to create a custom post type with custom fields to store your data, and look into AJAX or wp_localize_script to get your data to the front end Aug 3 '16 at 0:22
  • Hi Christophe, welcome to WPSE. Plugin recommendations are off-topic here so I've edited your question to remove that part of your request. As for the rest of your request, it is likely too broad for us to answer; are you able to edit your question with some rundown of what you have tried so far, so we can help specifically with where you're stuck?
    – Tim Malone
    Aug 3 '16 at 1:02
  • Hi @TimMalone, thanks for your answer and your notices. The problem is, I came here for techninal opinions and instructions because I don't have any clue where to start or what to search for to solve my issue. I expected an answer like that from czerspalace which shows me a direction and which concepts of WordPress are available to deal with JSON file export. I just need some technical advice which concepts I have to look into to figure it out for myself.
    – christophe
    Aug 3 '16 at 14:30
  • 1
    @christophe Opinions are not geared to the SE model. I would encourage you to read How to Ask and tour. Based on your rep and if you are looking for an opinion and guidance you're free to visit the chatroom. However, after your edit your question shows no effort, research or shows you attempted anything and it would require a very long tutorial to complete and that isn't in scope. Aug 3 '16 at 14:58
  • @Darth_Vader I don't want a tutorial here, I need someone to tell me what concept I am missing or I have to look into, so I can search for my problem properly. Right now I don't have a clue if it's even possible what I want to achieve nor which concepts of WP are a prerequisite. I didn't know that SE would be so dogmatic. I am looking for advice which direction I should head, not for someone to create a tutorial or code snippets for me.
    – christophe
    Aug 3 '16 at 15:29

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

  • Thank you so much, that's everything I wanted. Now I have a starting point!
    – christophe
    Aug 3 '16 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.