If you run a successful WordPress Blog with lots of traffic then you may be interested in Optimizing it. There are many simple alterations you can make to your WordPress files that result in a smoother running Blog. Say bye to “Too Many Database Connections” and similar errors!

The main issue with WordPress is that it is designed to work as soon as its installed so this means there are settings all over the place that require database access to pull information and the more concurrent database connections that your web site performs the slower your host and site will potentially run.

The easiest way to optimize your WordPress Blog is by editing your “header.php” Template file.

I will be using a free popular theme known as Arras to show you how optimizations can be made.

Open up the header.php file located inside your arras-theme directory and you should see the following:

================== HTML CODE ====================

<meta http-equiv=”Content-Type” content=”<?php bloginfo(‘html_type’); ?>; charset=<?php bloginfo(‘charset’); ?>” />
<title><?php arras_document_title() ?></title>
<?php arras_document_description() ?>
<?php if ( is_search() || is_author() ) : ?>
<meta name=”robots” content=”noindex, nofollow” />
<?php endif ?>
<?php arras_alternate_style() ?>
<?php if ( ($feed = arras_get_option(‘feed_url’) ) == ” ) : ?>
<link rel=”alternate” type=”application/rss+xml” href=”<?php bloginfo(‘rss2_url’) ?>” title=”<?php printf( __( ‘%s latest posts’, ‘arras’ ), wp_specialchars( get_bloginfo(‘name’), 1 ) ) ?>” />
<?php else : ?>
<link rel=”alternate” type=”application/rss+xml” href=”<?php echo $feed ?>” title=”<?php printf( __( ‘%s latest posts’, ‘arras’ ), wp_specialchars( get_bloginfo(‘name’), 1 ) ) ?>” />
<?php endif; ?>
<?php if ( ($comments_feed = arras_get_option(‘comments_feed_url’) ) == ” ) : ?>
<link rel=”alternate” type=”application/rss+xml” href=”<?php bloginfo(‘comments_rss2_url’) ?>” title=”<?php printf( __( ‘%s latest comments’, ‘arras’ ), wp_specialchars( get_bloginfo(‘name’), 1 ) ) ?>” />
<?php else : ?>
<link rel=”alternate” type=”application/rss+xml” href=”<?php echo $comments_feed ?>” title=”<?php printf( __( ‘%s latest comments’, ‘arras’ ), wp_specialchars( get_bloginfo(‘name’), 1 ) ) ?>” />
<?php endif; ?>
<link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />
<link rel=”shortcut icon” href=”<?php echo get_template_directory_uri() ?>/images/favicon.ico” />

================== / HTML CODE ====================

Now look at all those areas marked in Blue, these all require access to your WordPress Database to dynamically fill in the gaps potentially slowing down your Blog and Server. The thing is all these areas marked in Blue can be simply replaced so that no Database connection is required.

So change the above to…

================== HTML CODE ====================

<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8” />
<title><?php arras_document_title() ?></title>
<?php arras_document_description() ?>
<?php if ( is_search() || is_author() ) : ?>
<meta name=”robots” content=”noindex, nofollow” />
<?php endif ?>
<?php arras_alternate_style() ?>
<?php if ( ($feed = arras_get_option(‘feed_url’) ) == ” ) : ?>
<link rel=”alternate” type=”application/rss+xml” href=”http://www.YOURWEBSITE.com/feed” title=”WEBSITENAME latest posts” />
<?php else : ?>
<link rel=”alternate” type=”application/rss+xml” href=”http://www.YOURWEBSITE.com/feed” title=”WEBSITENAME latest posts” />
<?php endif; ?>
<?php if ( ($comments_feed = arras_get_option(‘comments_feed_url’) ) == ” ) : ?>
<link rel=”alternate” type=”application/rss+xml” href=”http://www.YOURWEBSITE.com/comments/feed” title=”WEBSITENAME latest comments” />
<?php else : ?>
<link rel=”alternate” type=”application/rss+xml” href=”http://www.YOURWEBSITE.com/comments/feed” title=”WEBSITENAME latest comments” />
<?php endif; ?>
<link rel=”pingback” href=”http://www.YOURWEBSITE.com/xmlrpc.php” />
<link rel=”shortcut icon” href=”http://www.YOURWEBSITE.com/favicon.ico” />

================== / HTML CODE ====================

If you run a Blog with many visitors you should notice an improvement, i have a blog with 20,000 visitors a day and before i applied these changes i was getting the common error “Too Many Database Connections”.

If you want to speed up your Blog even more then use the WordPress Plugin known as SuperCache

►  Make sure you check our Webmaster Forum for more Tips.
Posted in Tips

Tags: , , , , ,