Close Comments After X Amount Of Days

One thing I recently implemented on my WordPress blog is to close comments on posts older than 30 days. After 24 hours, I noticed my spam comments has dropped dramatically to zero. That’s a good thing.

To close comments on posts after x amount of days, all you have to do is access your WordPress Dashboard > Settings > Discussion page. Look for the option saying “automatically close comments older than  x days.” Here’s a snapshot of the page.

Snapshot

Just check it to turn on the feature. Supply the number of days that you want the comments to be turned on. Comments will be turned off on posts older than x number of days that you’ve provided. Simple enough. This is just another tool to help lower your blog’s spam comments. It certainly did on my blog.

Turning Off Post Revisions in WordPress

Post Revision is a WordPress feature that was introduced with WordPress version 2.6. Post revisions allowed WordPress users to go back to previous saved versions of a post. It’s a life-saving feature to those needing to roll back to a previous post.

Although this feature have saved countless individuals from potential lost work, it also can add some overhead to the database tables because it inserts a new record every time a post is saved.

I was more than curious to how much data could be saved if post revisions were deleted from the database. So, I embarked on a project to delete post revisions from my main blog, which happens to be a multi-site blog.

Prior to doing anything, I recommend that you backup your database via PHPMyAdmin. Backup all the tables. This is very important. I can’t stress this enough.

I use the instructions from Lester Chan’s article to turn off and delete post revisions. I didn’t hesitate using Lester’s instructions because he is well-known and trusted member in the WordPress community having written many valuable plugins.

Turn Off Revisions

You can turn off revisions by editing your wp-config.php file and adding the following:

define('WP_POST_REVISIONS', false);

Delete Post Revisions

You can delete post revisions from the wp_posts table by running this SQL statement from PHPMyAdmin. You may need to repeat the process if you have a multi-site blog.

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

Results

I have a total of 5 blogs running on my multi-site blog. Prior to deleting post revisions, my backup SQL file was 16.6MB. After deleting the post revisions, I was able to shave off 2.3MB. The file is now only 14.3MB. It doesn’t seem like a lot of saved space, although it deleted over 1000 rows.

Which brings me to the question, was it all worth it? Probably not. For the tiny amount of space saved, you are probably better off leaving post revisions alone, because you’ll never know if you need to revert to an older post. After all, it’s a nice feature to have.

Display On WordPress Single Pages Only

I recently had to display some content on my blog, only when my blog is displaying a single article or a single post. The content does not appear on the home page or any other page. Since my blog is powered by WordPress, there are several WordPress functions that I can use to detect if the current page is a single post, a home page or a WordPress Page, e.g. the About page. Here’s the code:

Single Posts

<?php if(is_single()) : ?>
My single post content goes here!
<?php endif; ?>

Home Page

<?php if(is_home()) : ?>
My home page content goes here!
<?php endif; ?>

Pages

<?php if(is_page()) : ?>
My Page content goes here!
<?php endif; ?>

The content located between the if and endif statements will be displayed only if the conditional is true. You can use this code to customize the content of your blog. You can place this code in your WordPress theme files such as index.php, home.php, single.php, and page.php.

Black-Letterhead 1.7.1

Black-Letterhead has been upgraded to version 1.7.1.

Download Black-Letterhead 1.7.1 now!

Version 1.7.1 essentially has the same features as version 1.7, but it contains a XSS security fix. I recommend that you upgrade to version 1.7.1 as soon as possible.

1.7.1 Features

  • Compatible with the latest WordPress 3.2.1
  • Automatic Feed Links
  • Post Thumbnal support
  • Custom Menus support
  • Custom Headers
  • Rotating Header Images
  • Custom Backgrounds
  • Theme Toolkit
  • Choose right or left sidebar
  • Two widths: 760px or 960px
  • Ability to remove Title or Tagline
  • Turn on/off Single Pages with Sidebar
  • Display Page border/No border
  • Ability to Customize Fonts
  • Ability to change Text Colors
  • XSS Search Fix

Download Black-Letterhead 1.7.1 now!

Is Automattic Moving Offices?

The SF Port Authority has shut down Pier 38, home of numerous startups including Automattic, the company behind WordPress. SF Port Authority says the building is unsafe and must vacated in the next 30 days. I wonder if Automattic has to move at all, since the office sits right outside of the pier. I’ve been to that office numerous times for WordPress meetups. The good thing is, most of Automattic employees work remotely and are hardly in the office anyways. Anyways, all tenants must move out of Pier 38 by September 30. It will be interesting where Automattic is moving if at all.

Difficult Passwords

Hacking sites seems to be in vogue nowadays. One of the easiest ways of hacking a website is by brute force. Having difficult passwords is the only way to go. There is no excuse to having a password like “password, admin or 1234.” You’re just asking for trouble.

There are several programs online that are available for free that can generate difficult to guess passwords. Most people don’t use them because are difficult to remember. But, don’t underestimate yourself. With enough repetition, you will be able to remember them, just like lyrics of old songs stored in your head.

Within a week of repetitive use, you can master your newly minted password in no time. But, don’t stop there. It is recommended and a good security practice to change your password every six months or so. So lock up your accounts. Use difficult passwords.

Black-Letterhead 1.7

After a year and a half hiatus, I’m releasing a new version of the Black-Letterhead theme. As some of you already know, the Black-Letterhead is a WordPress theme that I released under the GPL license several years ago. The latest version is now available for download to anyone for free. So, what are the new features?

View Demo | Download Black-Letterhead 1.7

New Features

  • Compatible with the latest WordPress 3.2.1
  • Automatic Feed Links
  • Post Thumbnal support
  • Custom Menus support
  • Custom Headers
  • Rotating Header Images
  • Custom Backgrounds
  • Theme Toolkit
  • Choose right or left sidebar
  • Two widths: 760px or 960px
  • Ability to remove Title or Tagline
  • Turn on/off Single Pages with Sidebar
  • Display Page border/No border
  • Ability to Customize Fonts
  • Ability to change Text Colors

View Demo | Download Black-Letterhead 1.7

Google to Rename Picasa and Blogger

Google plans to rename Picasa and Blogger. Picasa will become Google Photos. Blogger will become Google Blogs. This is all part of an effort to rebrand some of the older Google products with a Google name on them. Picasa was acquired by Google in 2004, while Blogger was acquired back in 2003. I still think Google made a mistake by buying Blogger, albeit WordPress was first released on May 27, 2003. Clearly, WordPress is the better blog platform now. Read more about the rebranding of Picasa and Blogger from Mashable.

Upgraded to WordPress 3.2

I just upgraded to WordPress 3.2. It looks mighty spiffy. The Admin pages have been redesigned with several new Admin features added. There’s a new default theme called “Twenty Eleven,” which I have yet to use. Perhaps, later. The coolest new feature is the new full screen editor. Adding or editing a post doesn’t seem like you’re working within WordPress at all. I love it. If you like to know more about WordPress 3.2, read the release notes.

WordPress 3.2 rocks! Update now.