Set Your Timezone Correctly In WordPress

It’s a new year, and it’s a good time to make a new start. I did a little bit of housekeeping work within WordPress, to make sure that my blog is off to a good start. I just changed theme today. That’s going very well. While browsing around my blog, I noticed that the time on my posts are off by one hour.

It doesn’t make any sense, since my webhost is Hostgator, which is based in Houston, which is in the Central timezone. I’m in California which is Pacific timezone. My blog, for some reason, seems to be in the middle, in the Mountain timezone. I did some little investigative work and found that my WordPress timezone settings has changed.

This post is about making sure that your WordPress timezone is set correctly. So, login to your Admin Dashboard. Access Settings > General look for the Timezone settings. See snapshot below.

Select your timezone correctly. I set mine to UTC-8 for the West Coast of the United States. If you don’t know where you are, you can check several websites that offer timezone information. Once you made the change, go ahead and save. You can validate your WordPress timezone setting by looking at the internal clock next to the form. It should display the correct time in your timezone.

You should only get to do this once, but my time setting, for some reason has changed, and I just recently noticed it. So, make sure to check that your timezone is setup correctly.

A New Theme

A new year, a new theme, a new framework, a somewhat familiar layout, and the same old background. The new theme is based on the Genesis framework by StudioPress. I’m using a child theme called News.

The new theme should be more flexible when it comes to layout and functionality. The Genesis framework is quite robust. The framework has a plugin called Simple Hooks that makes it easier to make theme customizations.

A piece of code can be inserted using Simple Hooks. It will accept any HTML, Javascript and PHP code. The hooks can do wonders when inserted in key sections of the framework. Plugins shortcodes can be inserted as well.

Overall, I’m still learning how to work with this framework works. The concept is a little foreign to what I am used to, but I like what I have done to the theme so far.

I hope you like the new theme.

2011 In Review

According to WordPress, I wrote a total of 190 posts in 2011. To see all the articles written in 2011, simply access:

http://ulyssesonline.com/2011/

This feature is possible using one of the nicest features in WordPress called permalinks, which is short for permanent links. With permalinks, you can customize your own URL structure the way you want it. I happen to use this format:

http://ulyssesonline.com/%year%/%monthnum%/%day%/%postname%/

which makes it easier for me to display articles by year, month and day. To access all articles written in 2011, I just provide the year and all articles written in 2011 will be displayed. Most WordPress users already use permalinks.

If you are not, do it early. Over the years, you’ll see the benefit of using such a structure.

The Reasons Why I Dont Use Internet Explorer

Every now and then, I use Internet Explorer just to see how an application behaves with the dreaded browser from Microsoft. The results at times are surprising, to say the least. Using IE usually involves using Windows, which I don’t use that often. But, I have my old, trusty Windows XP, running in Virtualbox.

Inside Windows XP, I have a slightly older Internet Exporer 7. I want to upgrade to IE9, but there is a slight problem. When I headed over to Microsoft’s website, I learned that I can’t run IE9 on Windows XP. Microsoft suggests that I upgrade to Windows 7. No thanks. So, the best I can do with this Windows XP, is go with IE8. I guess I can do that, but I need another computer to test IE9.

In the meantime, I decided to blog just a little. I logged in to WordPress using IE7. Guess what? WordPress complained that I’m using an insecure browser the moment I logged in to the WordPress Dashboard. The message is right up there on top of the page, inside a bright red background. You can’t miss it.

So, I decided to write a quick blog, and then the unimaginable happened. The IE7 browser disappeared. It’s gone in a puff of smoke, right before my eyes. Where did it go? It crashed! It’s a good thing, I pressed ‘Save Draft’ just moments before its disappearance. So, now I’m using Google Chrome to complete this post.

Oh, what fun. And I still have to test that dreaded application with IE7, IE8 and IE9. I can’t wait what’s in store for me.

WordPress 3.3 Upgrade

Unless, you are blind as a bat or need new glasses, you probably have seen the messages within WordPress, reminding you that you need to upgrade to WordPress 3.3. If that type of incessant nagging doesn’t get you to upgrade, I don’t know what does. So, I relented and upgraded several instances of my WordPress installs.

I use the WordPress upgrade via Subversion, but there were a couple of file conflicts in the upgrade. So, I ended up removing the .svn directories from the WordPress directories. I ended up upgrading WordPress via the easy and preferred, one-click method within the WordPress Dashboard.

So, what’s new with WordPress 3.3? The most obvious change is the redesign of the Dashboard. See snapshot of the Dashboard below. It’s supposed to be faster, functional and more accessible. To me, the eye candy of this whole upgrade is the new media uploader.

Uploading images into WordPress now supports the drag and drop of images into a media uploader. It’s makes uploading images much easier, if that wasn’t already the case. So, let me try a couple of images now.

The image above is a snapshot of the new Dashboard. As you can see, the Dashboard has been redesigned. It looks spiffy and neat. The image below is a partial snapshot of the new Media Uploader. As you can see, there’s a section where you can drop images for uploading.

To drag and drop images, I suggest that you minimize your browser, so that you can easily see and grab images from your Desktop. Just grab an image or several images to an area where it says “Drop files here” in media uploader. The media uploader will automatically upload the images for you. It’s impressive.

If you haven’t upgraded yet, I urge you to upgrade and take advantage of the new features of WordPress 3.3. Finally, here’s the obligatory video about WordPress 3.3.

A Background Image That Scales

I recently fixed an issue with my theme design. The dark wood background image that you see on this blog, was not big enough to fit most large monitors, where resolutions are higher than 1080px. Hat tip goes to Daniel Ritchie for pointing it out to me. So, I searched the web and found several possible solutions.

I found Chris Coyier’s at CSS-Tricks solution the most attractive, because it was by far the easiest one to implement. It not only adheres to CSS 3 standards, but it also works across most modern browsers. The result is a background image that fills up the entire page, scales to any size screen when needed, retains its aspect ratio, and centers the image properly.

What more can you ask for? Well, maybe something that loads a tiny bit faster than usual. So, I took the liberty to reduce the file size of my background image from 744kb to 128kb using my beloved Gimp. I use a little bit of image compression, without suffering too much in image quality. So, not only is the background image displaying properly on any size monitor, it also loads much, much faster. That’s a win-win situation.

If you like to know how I implemented a background image that scales to any screen resolution, just head on over to CSS-Tricks and check out Chris Coyier’s CSS3 solution. I hope you’ll find this article very helpful. I tested the new background with a HP w2207h monitor that rotates to landscape mode. Works great. If you find this to be otherwise, any input is appreciated.

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.