Tag Archives: Geo Mashup

A script to fix Geo Mashup update

On one of my web logs, I use a map to display the route of my travels. Each post is geo-tagged, so places can be connected with lines. It’s a very nice feature for a travel blog, thanks to the Geo Mashup plugin for WordPress. I recently updated the Geo Mashup plugin to a new version. For this version, the locations had to be converted to the new format. The result of this upgrade was that my route was no longer correct: posts seemed randomly connected to each other.

After some investigation, I found that Geo Mashup uses a special table to link posts and location to each other. This link also has a date and time connected to it. The results are ordered using this date. During the conversion, each link had the date of the conversion. Therefore, the results were displayed random.

I wrote a quick PHP script to fix this problem. This script looks at the time the original post was made, and updates the Geo Mashup table.

[code lang=”php”]

// username for the database
$USERNAME = ‘username’;

// password for the database
$PASSWORD = ‘password’;

// name of the database containing WordPress
$DATABASE = ‘wordpress’;

// host for the database (99% chance it will be localhost)
$HOST = ‘localhost’;


$link = mysql_connect($HOST,$USERNAME,$PASSWORD) or die(‘Cannot connect to database ‘.$HOST);
$x = mysql_select_db($DATABASE,$link) or die(‘Cannot select database ‘.$DATABASE);

$result = mysql_query(“SELECT * FROM wp_geo_mashup_location_relationships”);
while($row = mysql_fetch_assoc($result)
$result2 = mysql_query(“SELECT post_date FROM wp_posts WHERE id=”.$row[‘object_id’]);
mysql_query(“UPDATE wp_geo_mashup_location_relationships SET geo_date=\'” . $row2[‘post_date’] . “\'”);
After running this script, the problem was fixed, and my map displayed the correct route.