Calling all WP Stack Exchangers!
I am currently using Alain Gonzales’ Google Map Shortcode plug-in on a site I’m developing, and it’s worked just fine:
Google Map Shortcode plug-in on wordpress.org
Recently, I added a Custom Post Type (called “hotels”) to the site, and created two new Custom Taxonomies to use with this (“cities” and “regions”). I’d like to use the plug-in mentioned above to display map points for posts that use the CPT/Custom Taxonomies, and so far it will let me add the points in question, but doesn’t properly spit them out on the relevant theme template file – it only shows the first post within the taxonomy, but not the others.
In the plug-in file, there’s this line:
$post_obj = get_posts(array(‘category__in’=>$categories,’numberposts’=>-1));
This is used to query posts within a category and print out their associated map points; of course, the problem is that because Custom Taxonomies aren’t “traditional” categories, it doesn’t quite work with them 🙁
Can any of you guys think of a way I can query the taxonomies correctly to get the points from each post within them?
As always, any help would be gratefully received!
Sorry for reviving this post, but it was on the front page and I noticed that it’s very old too late… Here’s my take on this problem:
Basically we filter the shortcode attributes when we’re on a “cities” or “regions” taxonomy page and add a custom value for the “cat” parameter.
In the
pre_get_posts
action fired byWP_Query::get_posts()
we check if the custom values are present in thecategory__in
parameter – if so, we unset thecategory__in
parameter and add atax_query
parameter for the current taxonomy.simply follow this link
it will guide you through adding custom fields to custom taxonomy
from that point you can add html code in the new meta box created and insert your google map code there.then take the two points x,y and insert it in two text inputs and store them for your custom taxonomy.
http://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/
another link to add google map to custom post types.
http://www.billerickson.net/integrate-google-maps-wordpress/
thanks