You can display a map in your templates with the following code:
<?php if ( isset($wpgeo) ) $wpgeo->categoryMap(); ?>
This will display a map similar to the widget map with a marker for each post that is currently displayed. For example, you could insert this in your index, category and archive templates to show a map above the list of posts.
This ONLY shows markers for posts that are visible on the current page. It does not show markers for ALL posts in a category.
wpgeo_longitude() and wpgeo_latitude()
Outputs the longitude and latitude values.
wpgeo_title() and get_wpgeo_title()
Gets or outputs the marker title for the post.
wpgeo_post_map() and get_wpgeo_post_map()
Outputs the post map – use within the post loop.
wpgeo_check_version($version)
Checks is the WP Geo version is greater or equal to $version.
wpgeo_check_db_version($version)
Checks is the WP Geo database version is greater or equal to $version.
hi!
is there a shortcode which i can use in post’s body or a template tag to show the latitude/longitude values as text if there is a location for a post? i want to show the post’s location in the header of the post as text. how can i do this?
thanks, paul
Are you thinking of a something simple like
[longitude]and[latitude]shortcodes andlongitude()andlatitude()template tags?Is there a way to insert a tag into a page that will show a map mashup of all posts containing lat/long data?
For example, you click on the Mashup page and it would display a map that would scale just large enough to display all the pushpins associated with posts that contain lat/long.
I understand that for a large blog with many posts, this may be too much, but for smaller blogs it would kind of cool.
Hi Shane, that is the most requested feature and I am working on it! I have to rebuild some of the plugin to get it to work but it WILL be added – sometime soonish hopefully…
Hi,
really nice plugin indeed !!
I wanted as well a mashup page with all my posts on the map, to do a “mapped archive” page, so I watched your code a bit and found a solution without modifying it :
All you have to do is :
* Create a new template page with the appropriate “Template Name : XXXX” declaration at the beginning
* At the very beginning of the template, call you post query according to what you want to show on the map and assign it to the global $posts variable. For me :
global $posts;
$posts = get_posts(‘numberposts=-1&’);
* Now call the get_header() template tag. This will trigger your hook in wp_geo.php that prepares map’s data.
* Call the $wpgeo->categoryMap(); template tag in your template code to show the mashup map
Now you can create a new page within WordPress and set the page template to this new one, and it should show up with the map !
Thank you so much for this plugin, I’m gonna use it on my travel blog and it’s just perfect
Olivier
Olivier, I like your solution… I might write that up into a post for people wanting to achieve the same sort of effect. Is a good solution until I get the RSS mashup version working properly.
Olivier,
Your solution works partially. The thing is that after calling the function get_posts you are changing the query and because of that WordPress ignores other things such as the page title and so on.
Does anyone have another solution to display a map with all the posts from a category or similar?
Great plug-in, wondering how I put a label on the tag attached to the marker, mine just appears blank??
Thanks
Nice plugin!
I would like to show a tab ONLY if wpGeo is installed and active, but I’m not sure exactly how to do that.
Example:
if(function_exists(‘wpgeo’)) then show tab…otherwise show nothing
Which function should I check for?
Thanks!!
You could check if the WP Geo class exists and the $wpgeo instance has been created:
if ( class_exists(‘WPGeo’) && isset($wpgeo) )
Worked perfectly. Thanks!!
Thanks for this. My dad’s just started a travel site now he has retired and this worked great! Nice work.
I note there are different sized markers, but I don’t see an option to change them. I’d like to use the larger ones?
Also, be a nice feature to be able to specify a separate mini title, description and thumbnail image from the post page to spice it up a bit. That would be great. Any chance of any in that functionality?
Great work pal.
Hello Ben,
I’ve one question. This
global $posts;
$posts = get_posts(‘numberposts=-1&’);
is for posting all flags in a map and it works!
Now is this also possibile for posting flags in a map for only one category???
Thanks Jens
Yes, you should be able to use any or the parameters found on this page:
http://codex.wordpress.org/Template_Tags/get_posts
Hi Ben,
I tryed it with this 3 versions:
But it doesn´t work…. look here http://www.milchladen.de/weltkarte/map-cape-2-nairobi/
I can´t good php! Yes I know….shame over me
Look this
global $posts;
$myposts = get_posts(‘numberposts=-1&offset=1&category=25′);
global $posts;
$myposts = get_posts(‘offset=1&category=25′);
global $posts;
$myposts = get_posts(‘category=25′);
Hi Ben,
you’ve an solution for this problem??
Thanks, Jens
Hi there!
Really great plugin!
I try to use the map in my search results template to display all locations according to the search term. However it does not work (no map is displayed).
Any hints?
Hi
Is there a template tag to show the map on a single post/page. I want to do a check to see if I’m on a custom post and then only show the map on my custom post. Not in regular post/pages.
Something like (havent tried this)
Map(); ?>
Is there a template tag to just display the name of the location? I am trying to use the pluging to automatically display the meta like this posted by in .
Thanks,
Steve Shoppman
Not current but it will be easy to add. I’ll try to get that into the next release – added to list.
Is there a way to set a custom map center and zoom with the template tag?
Ben, the earlier versions were working fine, but now the maps don’t show on our Beaches website which is the most prominent beach site on the internet. I’m not sure if it has to do with the Thesis theme we use. Any suggestions?
Thanks! Dave
Hello,
I am trying to figure out how to add wp-geo to a custom post type in WP 3.0.1. I think I need to hook it into my my register_post_type() function but am unsure of the syntax needed. Can I simply include the wp-geo php file?
How have you added the custom post type?
In theory if you install WP Geo and go to the WP Geo settings page there should be a checkbox to turn on for your custom post type.
Or when you’re registering your post type, when you set the things your post type supports (comments, revisions etc) you can add “wpgeo” to this list.
Hi Ben,
Thanx for the tip, I ended up using add_post_type_support but will change to using wpgeo in the post type registration function.
Thanx again!
sorry forgot to ask:
For some reason my lats and longs show up using the template tags but not the map itself. The size is displayed but the map is all black. Any ideas?
Thanx, Daniel