Pages

Showing posts with label WordPress Hacks. Show all posts
Showing posts with label WordPress Hacks. Show all posts

Optimize and Speed Up Your Wordpress Blog

If your blog is on shared host but starting to get some serious traffic, then you are probably having problems with slow database queries, and in the future you might even be suspended because of exceeded CPU quota. The outcome will be frustration on your side and annoyed visitors on the other side.

The first reaction will be to file dozens of support tickets with the hosting company. After that you might consider moving to VPS or Dedicated Server, but before doing that you should try some tricks to improve the loading speed of your blog and survive higher traffic on shared hosting.

Important: before attempting to do anything with your blog please make a fresh backup of your database and WordPress files.

1. Use just few necessary plug-ins.

The less plug-ins you have, greater loading speed you achieve. So deactivate and delete the plug-ins that are not really necessary for your blog.

2. Use pure code in your sidebar instead of widgets.

This one seems radical but it’s very easy to implement. Make a research and you’ll find code examples for showing recent posts, categories, tags, etc. on your sidebar without use of any widgets.

3. Disable post revisions.

Post revisions are only building up your Database with records. The only thing you have to do is to put the following line in your wp-config.php file:

define('WP_POST_REVISIONS', false);

4. Remove extra tables in Wordpress Database.

Login to your host, go to your phpMyadmin, open your blog database and you’ll see the table structure of your wordpress database. The default DB tables for wordpress are these ones:

  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_usermeta
  • wp_users

If you have some extra tables (which are not used by your plugins at this moment) delete them. They are there just because you’ve installed and uninstalled plugins in the past. Some of the plugins create extra tables in the DB and when you decide to remove them some of the tables are staying there. You don’t need them, so drop them.

5. Clean up your Wordpress Database.

For this step you’ll need one very useful plug-in. It’s called Clean Options.

Install it, activate it and use it to clean up your wordpress database. It will erase unnecessary, redounded, orphaned records. Then you are done with this plug-in, so deactivate it and delete it. After doing this, please test your blog and plug-ins for functionality. If some of your plug-ins stopped working, just reinstall them and you’ll be fine.

6. Repair and optimize your Wordpress Database.

Go to phpMyadmin again, select your database check all the tables, and in the dropdown menu select repair. Select the database again, check all the tables, and in the dropdown menu select optimize.

7. Change php code with html where applicable.

This tip is probably the most powerful of all these tips. The point is that in the header (sometimes footer and sidebars) of your wordpress theme you have php strings that every time when your blog loads they call your blog name, location of favicon.ico, stylesheet, ping file, feeds, charset etc.

All these php requests are slowing down your blog so why not changing them to static html code.

For example the following code:

<link rel=”stylesheet” type=”text/css” media=”screen” href=”<?php bloginfo(’stylesheet_url’); ?>” />

Can be changed to:

<link rel=”stylesheet” type=”text/css” media=”screen” href=”http://your-domain-here.com/wp-content/themes/your-theme- folder-here/style.css” />

You can also:

  • make your pingback URL static,
  • make your feed URL’s static,
  • you can remove the blog’s WordPress version,
  • make your blog’s name and tagline/description static.

The easiest way to do this is to compare the actual header code of your blog with the outcome header code (right click, view source code in your browser). Look at the original php code and see what the results are in the outcome source code of your blog. By doing this you will realize which php lines you can change to static html lines. Don’t be afraid to experiment.

8. And finally use WP-Supercache plug-in.

Probably you’re already using this plug-in, but for the ones who don’t you should know that it will greatly speed up your blog since it saves and stores static html pages of your blog and serves them to the browser without any heavy impact on your host.

9. Bonus tip:

Optimize your files (CSS, Javascript, images, video) and don’t overdo it with external loads (CPM combo ads, scripts etc.)

The intention of covering these tips was not to give you thorough technical knowledge, but to inspire you to experiment and research. These tips will give remarkable results and you’ll be really stunned when you’ll see how fast your blog loads even on a shared host. I personally tried all of them and I can guarantee that they have truly amazing effect.

Page Sensitive Multi-Level Navigation

While most sites don’t need incredibly deep page navigation there are situations that justify a hierarchy beyond the typical 2 – 3 levels. Unfortunately that can be cumbersome for top navigation drop-downs (more than 1 level of drop down is too much IMHO) so another solution needs to be found. I ran into just such a situation for a client and while I”m also not a fan of left hand navigation it was the decision of the client to utilize it in conjunction with their top navigation, and in retrospect it made sense for them. To keep things easily navigable we also implemented breadcrumbs (which is a good practice anyway).

The mission was to display sub-pages of the current page you are on in the left nav and once you hit the bottom of the hierarchy to show pages which are parallel to that page within the same branch of the hierarchy.

After some digging and experimentation I came up with the following which executes perfectly in only a few lines of code.

<?php
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
if ($children == "")
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
?>
<ul>
<?php echo $children; ?>
</ul>
<?php endif; ?>

Of course you style to taste…

That’s it! Used in conjunction with a standard WordPress top-navigation and breadcrumbs you can easily display page sensitive multi-level navigation for your super-complex multi-level site!
Sponsored by PTCSA DIGITAL NEWS, Sarkari Naukri-Current Vacancy.