English 中文(简体)
露言显示通过行政绘制的景象地图
原标题:Wordpress display google maps for places through admin

I m making a website for a freelance educator, who makes his lectures on 3-4 different places. I would want to have a google map attached on bottom of the posts where these lectures are occurring. Is it possible to have a selection of 3-4 radio buttons with these places in the Admin Post-editor, which would insert the google maps iframe through the theme?

Thanks for the help.

BR-:g

最佳回答

可能比较容易,但这样做的一种方式是:

  1. create a custom post type (CPT) called Location
  2. install WP Geo (or similar) and enable it for your new CPT, so each one can be associated with a specific location, and
  3. 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): Field definition

The field will appear in the entry editor like this: Page Edit

为了在守则中登出地图,在模板中添加这样的内容:

    <?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&amp;ie=UTF8&amp;t=m&amp;ll=-37.81609,144.967175&amp;spn=0.011866,0.024033&amp;z=15&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&amp;ie=UTF8&amp;t=m&amp;ll=-37.81609,144.967175&amp;spn=0.011866,0.024033&amp;z=15&amp;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&amp;ie=UTF8&amp;t=m&amp;ll=51.508101,-0.128059&amp;spn=0.018697,0.048065&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&amp;ie=UTF8&amp;t=m&amp;ll=51.508101,-0.128059&amp;spn=0.018697,0.048065&amp;z=15&amp;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&amp;ie=UTF8&amp;t=m&amp;ll=46.198369,6.142302&amp;spn=0.020793,0.048065&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?gl=uk&amp;ie=UTF8&amp;t=m&amp;ll=46.198369,6.142302&amp;spn=0.020793,0.048065&amp;z=14&amp;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.

问题回答

暂无回答




相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签