Use a lightweight plugin to prevent Windows Live Writer from littering your WordPress blog with Temporary Posts Used For Theme Detection.
Windows Live Writer is a neat tool for blogging. But its most useful feature, WYSIWYG editing, relies on an inelegant mechanism to detect the theme used by your blog.
To detect the theme, Windows Live Writer will publish a skeleton post to your blog, read it and save its theme, and then delete it. Sometimes the post isn’t deleted. Other times, it’s indexed by Google, FeedBurner, or other similar services before it’s deleted.
The result is an Internet littered with Temporary Posts Used For Theme Detection.
Obsessive compulsives like me don’t want these posts associated with their blogs. Thankfully, it turns out that you can write a plugin for WordPress to prevent these posts from ever appearing on your website.
Step-by-Step
Create a new text file called live-writer-helper.php
. Copy and paste the below code into that text file, and save it.
<?php
/*
Plugin Name: Live Writer Helper
Plugin URI: https://chris.dziemborowicz.com/blog/2009/11/17/how-to-get-rid-of-temporary-posts-used-for-theme-detection-permanently/
Version: 1.1
Author: Chris Dziemborowicz
Author URI: https://chris.dziemborowicz.com/
Description: Prevents the Temporary Post Used For Theme Detection from ever appearing on your blog.
*/
function lwh_posts_where($where)
{
if(!is_admin() && strpos($_SERVER['HTTP_USER_AGENT'], 'Windows Live Writer') === false)
{
if ($where != '')
$where .= ' AND ';
$where .= 'post_title NOT LIKE \'Temporary Post Used For % Detection (%)\'';
}
return $where;
}
add_filter('posts_where', 'lwh_posts_where');
Create a new directory called live-writer-helper
in your wp-content/plugins
directory, and upload live-writer-helper.php
to the new directory. Finally, activate the plugin by logging into WordPress as an administrator, selecting Plugins from the menu, and selecting Activate for the Live Writer Helper plugin.
The plugin works by hiding any post where the title is ‘Temporary Post Used For * Detection (*)’ from all pages on your blog, as well as from your RSS feed. Users and bots accessing your site, or your RSS feed, won’t be able to see the temporary post.
You can still view the post when logged into the management interface (ie, when logged into wp-admin
), so that you can delete the post if it hasn’t been deleted automatically. And, of course, Windows Live Writer can see it too, so that its theme detection engine continues to work.
Hopefully, this will end the flood of Temporary Posts Used For Theme Detection, at least on WordPress blogs.
Note: The present version of Windows Live Writer creates a post titled ‘Temporary Post Used For Theme Detection (*)’. Old versions created posts titled ‘Temporary Post Used For Style Detection (*)’.
If, in a future release, the title of the temporary post changes to something other than ‘Temporary Post Used For * Detection (*)’, you will need to update the code accordingly. (The %
is a wildcard in the SQL WHERE clause.)