Problem

The WordPress plugin Geo Mashup (http://wordpress.org/extend/plugins/geo-mashup/) has a problem displaying the correct post detail when a post is clicked on a map other then in the default language (posts are translated by Sitepress WPML (http://wpml.org).

Map in default language:

Map in another language:

As you can see in the examples above the post in the other language is not shown.

Solution

First of all copy the file /wp-content/plugins/geo-mashup/info-window-default.php to your template directory and rename it to geo-mashup-info-window.php.

Now open your favorite text editor and edit the geo-mashup-info-window.php.

Replace the following :

<?php else : ?>

<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn’t here.</p>

<?php endif; ?>

By this :

<?php else : ?>

<?php

$object_ids = $_GET['object_ids'];

if ( !is_array( $object_ids ) ) {
$object_ids = split( ‘,’, $object_ids );
}

// Create a new instance
$query_vars = array( ‘post__in’ => $object_ids, ‘post_status’ => ‘publish’ );
$second_query = new WP_Query( $query_vars );

// The Loop
while( $second_query->have_posts() ) : $second_query->the_post();
?>
<h2><?php the_title(); ?></h2>
<div>
<?php the_content(); ?>
</div>
<?php
endwhile;

wp_reset_postdata();

?>

<?php endif; ?>

Save the file and open the map in another language then the default.  Click on a point on the map and see the magic happens.  The correct post is shown!

5 reacties

  1. Geplaatst op 19/05/2011 om 14:57 | Permalink

    Great solution. Did you suggest it to the Geo Mashup authors?

    It doesn’t break anything for single-language sites and makes a big difference for multilingual sites.

  2. tom
    Geplaatst op 19/05/2011 om 15:39 | Permalink

    Amir,

    Thanks for your comment. I sent an email to the developer of Geo Mashup referring to this blog post.

    Tom

  3. Geplaatst op 19/05/2011 om 15:50 | Permalink

    Geo Mashup author here – thanks!

    This at least gives me an idea why the Geo Mashup query isn’t working. My suspicion is that this technique will not work for a custom post type, though. Would it be easy to test that on your site?

    Here’s where I’m tracking progress on this issue:

    http://code.google.com/p/wordpress-geo-mashup/issues/detail?id=435

  4. Geplaatst op 19/05/2011 om 15:53 | Permalink

    I just recalled that there’s open issue with custom post types and some of the plugins for creating them. Here’s one I know works: http://wordpress.org/extend/plugins/custom-post-type-ui/

  5. tom
    Geplaatst op 19/05/2011 om 17:48 | Permalink

    Cyberhobo, I’ve setup a test environment on http://tom.iben.ch. I created a Custom Post Type resellers (categories enabled). Installed WMPL (2 languages – english & dutch), installed Geo Mashup.

    I created a Reseller in 2 languages and tried above solution. It did not work. I had to add an extra parameter to the $query_vars variable in the geo-mashup-info-window.php file in my theme directory.

    Instead of :
    $query_vars = array( ‘post__in’ => $object_ids, ‘post_status’ => ‘publish’ );

    I did this :
    $query_vars = array( ‘post__in’ => $object_ids, ‘post_status’ => ‘publish’, ‘post_type’ => ‘resellers’ );

    Now you can see that http://tom.iben.ch/resellers/ shows the correct information of my reseller in English and http://tom.iben.ch/nl/verkooppunten/ shows correct information of my reseller in Dutch.

    Because Geo Mashup has only an option to show maps for certain categories (parameter map_cat), I have created a category Resellers and translated this into Verkooppunten. In my page where I show the map I use for English : [geo_mashup_map map_cat='6'] and [geo_mashup_map map_cat='8'] for Dutch. Maybe the developer can add another parameter (map_tax) to the plugin so we can use our own custom taxonomies.

    cheers,
    Tom

Neem contact op

Offerteaanvraag, of zin om eens te praten over je project bij een versgemalen kop koffie? Laat ons wat weten en we maken een vrijblijvende afspraak:

Grote Steenweg 91
B-2600 Antwerpen
Belgium

Tel.: +32 (0)3 286 8040
Mail : mark@motionmill.com