php
1<?php 2/* 3Template Name Posts: Name 4*/ 5?> 6get_header(); 7if(have_posts()): while(have_posts()):the_post(); ?> 8 9<?php echo '<h3>タイトル:'.get_the_title().'</h3>'; ?><br/> 10<?php 11 // If we are in a loop we can get the post ID easily 12 $lot = get_post_meta( get_the_ID(), 'lon', true ); 13 echo 'lot:'.$lot; 14?> 15<br/> 16<!--メタデータ取得 lat --> 17<?php 18 // If we are in a loop we can get the post ID easily 19 $lat = get_post_meta( get_the_ID(), 'lat', true ); 20 echo 'lat:'.$lat; 21?> 22<br/> 23 24<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 25 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 26 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 27 <head> 28 <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 29 <title></title> 30 <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=自分のキー" type="text/javascript"></script> 31 <script type="text/javascript"> 32 //ここがメタボックスから取ってきたい緯度経度 33 var lon=get_post_meta( get_the_ID(), 'lon', true ); 34 var lat=get_post_meta( get_the_ID(), 'lat', true ); 35 36 function initialize() { 37 if (GBrowserIsCompatible()) { 38 var map = new GMap2(document.getElementById("map_canvas")); 39 //ここに変数を入れるイメージ 40 map.setCenter(new GLatLng(lon, lat), 13); 41 } 42 } 43 </script> 44 </head> 45 <body onload="initialize()" onunload="GUnload()"> 46 <div id="map_canvas" style="width: 500px; height: 300px"></div> 47 </body> 48 </html> 49 50<?php endwhile; endif; 51get_sidebar(); 52get_footer();?> 53
wordpressで新規追加でメタボックスに緯度経度を入力し、その緯度経度の場所をgooglemapで表示したいのですが、現状だとget_post_meta is not definedというエラ―が出ます。何か良い方法はないでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/04 14:30