How to Optimize Your Wordpress Themes

WordPress is well written, there is not doubt about it. However, on the other side of things WordPress ca be bogged down with unnecessary function calls in your WordPress themes. WordPress was written to be completely dynamic, meaning you can plug-ins and themes adapt to the settings you have, let’s say you blog title. This is stored in a setting, and theme designers enter a piece of code that calls for this setting making it dynamic to if you change you blog’s name.

When redesigning Code and Coffee, I came across a lot of functions that you replace with hard coded information to reduce some of the work PHP has to do. For example: <?php bloginfo(’name’); ?>. This function, as stated above, simple prints out your blogs name. If you search your themes directory, you will probably see this come up several times. You can take it a step further ad search for anything that uses the bloginfo(); function, and hard code that information in as well. You will probably see things like “feed url”, “description”, etc. Each time you replace these functions with hard coded information, you are saving a step for PHP and some computational time. It may not be much, but if you have a blog that has lots of visitors every seconds counts when it comes t page loads. Unless you use a caching plugin like WP-Cache, you blog is calling these functions every time a page is loaded.

Now the only set back is, if you change around this information you will have to update it in the code not just WordPress’s administration panel. But how often does one change the name of their blog? I took it the extra mile, and removed a lot of calculations from the themes, even the page links… I hard coded those in because I do not change around my pages very often.

If one really feels gutsy they can go in and remove the code that loads all of this information into memory, but when you stray outside of themes and plug ins and start modifying the WordPress code base it makes it difficult to do updates.

Let me know how many functions you remove from your themes.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Sorry, the comment form is closed at this time.