可能比较容易,但这样做的一种方式是:
- create a custom post type (CPT) called Location
- install WP Geo (or similar) and enable it for your new CPT, so each one can be associated with a specific location, and
- Use the Posts 2 Posts plugin to associate the posts (lecture details) with a Location
您可能必须写一部小的法典,确定一个职位的相关位置,并将WPG功能称作地图,但如果你有一些编码经验,就应当做到简单明了。
EDIT
Ok, since you re keen on custom fields, try this. Install the Advanced Custom Fields plugin, which ll give you radio buttons for the custom fields (I don t think it s possible by default). Set up a new Field Group called "Course Details", with a single field called "Location". Associate it with a the appropriate entry type (page or post):
The field will appear in the entry editor like this:
为了在守则中登出地图,在模板中添加这样的内容:
<?php
switch (get_field( location )) {
case "melbourne":
?><iframe width="560" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=-37.81609,144.967175&spn=0.011866,0.024033&z=15&output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=-37.81609,144.967175&spn=0.011866,0.024033&z=15&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small><?php
break;
case "london":
?><iframe width="560" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=51.508101,-0.128059&spn=0.018697,0.048065&z=14&output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=51.508101,-0.128059&spn=0.018697,0.048065&z=15&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small><?php
break;
case "geneva":
?><iframe width="560" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=46.198369,6.142302&spn=0.020793,0.048065&z=14&output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&ie=UTF8&t=m&ll=46.198369,6.142302&spn=0.020793,0.048065&z=14&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small><?php
break;
} ?>
The code s just a quick and ugly example, but it should give you an idea of how to use the field. The URLs come straight from Google Maps - I just clicked the link icon, followed by "Customise and preview embedded map" to get the size I was after.