Google map mashups for different custom post types...but they don't have tags!

I have two Custom Post Types: Courses and Events.

I want to have a page: "Courses by Location" which shows a map mashup of all courses.

And a page: "Events by Location," which shows, you guessed it, a map mashup of all events.

(What I don't want is one giant mashup showing everything.)

I know that I can do this by adding the short code to the appropriate page:
[map query="tag=tagname"]

But wait a minute, Custom Post Types don't have tags. And also I wouldn't want to have to select a tag for each and every post anyway.

Is there a way to hard code a pretend tag into my Courses and Events so that I never have to think about it again, and so that this handy short code will just work?

Thanks! :smiley:

  • Mason

    Hiya,

    There's currently no way to query by post type for the mapping plugin. We can add that as a feature request though.

    You can register a custom taxonomy for custom post types as well. This would allow you to use the current tag query. Adding this wordpress snippet to the functions.php will enable tag selection within the editor for that custom post type. Don’t forget to change the CUSTOM_POST_TYPE to the name of the custom post type you created.

    function reg_tag() {
    	 register_taxonomy_for_object_type('post_tag', 'CUSTOM_POST_TYPE');
    }
    add_action('init', 'reg_tag');

    Hope that helps!

  • Vladislav

    Hi,

    Just a quick clarification, querying custom post types isn't supported across network. However, if you have a single blog (or you intend to create a mashup for a single blog), you can actually query custom post types out of the box, using the query attribute.

    Suppose your custom post type is named "test_cpt" (this is the custom post type name, as recognized by WordPress, not its label), and you want to show all maps associated with all posts of this type on one page. To show all the maps as one merged map, you could use something like this:

    [map query="post_type=test_cpt" overlay="true"]

    The new map will inherit the rest of the settings from your plugin defaults. You can also add some customization, e.g.:

    [map query="post_type=test_cpt" overlay="true" zoom="8" map_type="SATELLITE" show_images="false" height="300" width="100%"]

    Again, please note that this won't work for network-wide queries (shortcodes with network="true").

    Of course, you'll have to substitute "test_cpt" with your actual custom post type name. I hope this helps you a bit.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.