Every once in a while people will ask me to fix their blog, because it is either slow, or broken. Most of the time this is caused by either broken plugins, or broken themes. There are a few things I tend to do when I get to clean up stuff, and I though I would list them for you.
Clean up your theme
header.php
First of all, what I do is make the header.php file do a lot less queries. Because themes have to be easy to spread, they have to get almost all the blog specific info from the database. That results in a lot of queries for stuff that you could just hardcode into the theme. Some examples, taken from the default kubrick theme:
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="
<?php bloginfo(html_type); ?>;
charset=<?php bloginfo(charset); ?>" />
Could just as well be:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
You can also:
* make your stylesheet URL is static
* make your pingback URL static
* make your feed URL is static
* you can remove the blog is WordPress version
* make your blog is name and tagline / description static
Doing all that, you can remove 11 queries to the database, and this can highly speed up your theme.
footer.php
The default theme also has some of these calls to the database in the footer which you can make static, or remove altogether:
* your blog is name
* RSS feed URL
* Comment RSS feed URL
You can also remove all comments that aren necessary, like "If you would like to support WordPress, having the "powered by" link somewhere on your blog is the best way; it is our only promotion or advertising." I can tell you that that line is in a LOT of footers, and it is a waist of bandwidth once you have decided to leave the link for WordPress in or not.
Check your coding habits
You will have added code to your themes for your plugins. Let is say you have a line of code like the one below, for a plugin that thanks people coming from search engines:
<?php refer_thanks(); ?>
This creates a problem, as soon as you, by accident or another cause, disable the plugin that holds the refer_thanks function. When the function doesn exist, the code errors out, and your page doesn continue to load, thereby breaking your blog. To fix this, PHP offers a special function called function_exists, and using it, the code would look like this:
<?php if (function_exists( arefer_thanks)) { refer_thanks(); } ?>
Now, if the function doesn exist, your theme, and thus your blog, won break. It is probably a good idea to do this for every line of code you added for a plugin.
source: yoast
Related Stuff
8 Fail Safe Tips On Creating An Awesome 404 PageOh the 404! Such a wonderful error to come across while browsing the web. Some are funny while others are ...
12 Essential Tips to Build Your First Wordpress ThemeI always wanted to contribute to the wordpress community by building a Wordpress theme and releasing it to public. After efforts of 20 days ...
SEO Your Wordpress TemplatesLike many people, when I first started blogging, I discovered Wordpress and it’s many features that made it easy to set up and get ...
Facebook Connect Wordpress Plugin LeakedA few sources have alerted me to a project that Facebook has been working on: integrating Facebook Connect directly with ...
Why is SEO so important to your siteYou have heard the phrase LOCATION LOCATION LOCATION. But wait, this is online! You don’t have to worry about location… or do ...
Be the first ... |Add your comment.
Your Comment ...
Name (required)
Email (required, hidden)
Website
