WordPress customization, part II: electric boogaloo

Continuing from last time:

Today I’ve got three goals.

  • remove all commenting ability
  • modify sidebar to remove admin links
  • put WordPress content on the front page of steveshaw.ca

The first two are necessary conditions for the last one: I don’t want to deal with spammy comments or hijack attempts.

Remove commenting ability

I think it would be great if WordPress had a “turn off commenting” feature. I know that it may go against the whole internet-as-discussion model, but seriously there is more spam than actual discussion on most WordPress sites. I’d rather not deal with it and let people contact me/write in their own blogs with feedback.

What WordPress does give us is a configuration entry under Settings > Discussion, “Allow people to post comments on new articles”. Unclick that and people cannot comment on new posts. However, existing posts are open for plunder. To stop that, go to your dashboard, select “Posts”, click everything, select “Edit” action from bulk actions, select Comments > Do not allow. Apply the changes,

Unfortunately, this only works for posts – not pages . In WordPress, “posts” are normal blog entries and “pages” are semi-permanent web pages that are handled differently. There is no way that I’ve discovered to turn off commenting on a page using only WP configuration.

There’s another problem: the front-page slug still has a “Leave a comment” link on the page, which simply takes you to the full post page that doesn’t have a comment space.

So! Here’s what I did:

  • turn off comments on new articles and all existing articles as outlined above
  • modify page template so there are no comments
  • modify front-page post template so there is no comment prompt

In the Twenty Ten theme that is the parent of my theme, some of this magic happens in loop.php. So I copied loop.php into my child theme directory and made the following changes:

  • remove all of the comments-link spans. There were three in the template that I changed.
  • remove the meta-sep spans that immediately precede the comment-link spans. This will stop a stray meta separator from showing up at the bottom of your post.
  • remove the comments_template php block. There was only one in the template that I changed.

That leaves the comment block on the non-post pages.

  • copy loop-page.php to the child theme directory.
  • remove the comments_template php block. There was only one in the template that I changed.

Repeat this process for loop-single.php, the template file for displaying a single post on the page.

Now there should be no way for someone to enter comments on the site.

Remove admin links

The “Recent Comments” and “Meta” widgets on the sidebar are largely useless to me. About the only thing that could be of use is the RSS feed for posts, which I may add back in later. Removing these widgets is easy: go to your dashboard, select Appearance -> Widgets, and drop the widgets from the Primary Widget Area back into the Available Widgets area. This will remove them from your sidebar.

Put WordPress content on the front page

Once the new template files are uploaded from my local machine to the server, I figure it’s time to publish the blog to the front page of steveshaw.ca. This is super-easy as well: on the dashboard, select Settings and enter the desired URL in the Site Address field. For example, I entered http://www.steveshaw.ca/ into the field. And as outlined here, I had to move index.php and .htaccess from my WordPress install directory to the root of my web site.