Skip to content

Prevent Jetpack From Displaying Geolocation Data

Jetpack, turns out, will append geolocation data—if such data exists, that is—to your posts. And there doesn’t seem to be a pretty way to disable that behavior, i.e., there’s no mention of it on wp-admin/admin.php?page=jetpack_modules.

Some context: I recently decided to experiment with my Micropub client’s location function (and added a custom meta box to WordPress’s admin interface as well) to be able to add a latitude and longitude, and, occasionally, a location name to my posts.

Now, my site’s front end is all custom; it doesn’t even call the_content, like, ever. But the bit of code I use to crosspost (complete statuses) to Mastodon does, and that’s how I found out.

Anyhow, this works:

if ( class_exists( 'Jetpack_Geo_Location' ) ) {
  // Prevent Jetpack from appending geolocation data to `$post->post_content`.
    array( Jetpack_Geo_Location::init(), 'the_content_microformat' )

Jetpack’s source code mentions yet another filter, but that second filter doesn’t seem to actually do anything if your theme doesn’t explicitly declare support for the feature—mine doesn’t.

Oh, and none of this would’ve happened, had I called my custom fields something other than geo_latitude and geo_longitude. Figured I’d use these because Simple Location plugin does so, too, in case I’d ever wanna switch to a real plugin.


  1. Martijn 🐖 Martijn 🐖 on

    … favorited this!