index.php

function createMarker(lat, lng){
 //        マーカの作成
          var marker = new google.maps.Marker({
            position: new google.maps.LatLng(lat, lng),
            map: map
          });
      }

  jQuery(function ($) {
    $.ajax({
      type: 'POST',
      url: wp_url_admin_ajax,
      data: {
        'action': 'tell_me'
      },
      success: function (response) {
        json = eval("(" + response + ")");
        if (json.err) {
          result = "error:404";
        } else {
          console.log(json);
        }
      }
    });
  });

admin-ajax.php

add_action('wp_ajax_tell_me', 'tell_me');  
add_action('wp_ajax_nopriv_tell_me', 'tell_me'); 
function tell_me() {
    $data = array();
    $count = 0;
    for($i = 1391; $i < 1613; $i++){ //1391-1612 // 必要な情報の取得
        $data[$count]['name'] = get_post_meta($i,'name',true);
        $data[$count]['lat'] = get_post_meta($i,'lat',true);
        $data[$count]['lng'] = get_post_meta($i,'lng',true);
        $data[$count]['address'] = get_post_meta($i,'address',true);
        $count++;
        }
  echo json_encode($data, JSON_UNESCAPED_UNICODE);
  die();

関連記事