WordPress attachment spam

One year later and I still have to manually edit a core WordPress file after every release because they STILL haven’t patched it themselves, meaning that even if you set comments to closed after a certain period, all the attachment pages under the post still get hit by spam comments.
Come on WP…

Fighting comment spam

As I mentioned before, I’m being hit by comment spam at a rate of hundreds a day. Akismet flags them as spam thank god, but I’d still prefer them not to even get recorded to begin with.
It seems automated and hitting older posts, so in an attempt to stop the tide I’ve disabled comments on posts older than 90 days. Unfortunately WordPress disregards its own settings when it comes to attachment pages, for this I had to sneak into wp-includes/comment.php and modify 2 lines.
In my current version (3.3.2) it’s lines 1963 & 2002, where I changed
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post', 'attachment' ) );
Fingers crossed.

Website screenshots for lazy people

If you use a lot of screenshots of websites for your blog you can easily make them through the wonders of
Here is the URL:
All you have to do is insert your required URL in the place of the ‘’ part of the link and resize (‘w=300′) to your required width.

Disable automatic WordPress paragraphs

WordPress automatically wraps content in html paragraphs. Sometimes this can be undesired, for example when you’re making one-liner posts using the new post formats for links or status updates. The easiest way around this is by setting the filter in your template.
It looks like this, snippet taken from my format-status.php:

the_content('Read more...');

First we use remove_filter to tell WordPress not to use automatic < p> tags for the_content, then we output the content, and immediately afterwards we use add_filter to restore the filter or it’ll also be off for all the subsequent posts on the page.

SQL to change your WordPress links

A simple quickie in case I ever forget, and you might like it too.
Say you have static content, like a folder of pictures, you want to move or rename. But all your posts link to the old folder.
Here’s a quick way to update all your posts in sql, for example using phpMyAdmin:
update wp_posts set post_content = replace(post_content, '\/anime\/pics', '\/anime2\/pics');
In my case this replaces all the links containing ‘/anime/pics’ with ‘/anime2/pics’ as that’s what I renamed the anime folder to.
Note the \/ in the sql statement, you need to escape all your / slashes in the statement by putting a \ before it, or your get errors.

Work in progress... not home!
Trying to get all/most of the new code working before I start on the eyecandy.