Currently Browsing: WP Tweaks

Efficient or non-efficient?

All of you out there that know me, know that i am an efficiency freak. Most of the times, when someone flashes a plugin to me, i stop and say “is that really necessary?” instead of “this looks cool!”. I know, it’s mostly annoying but you got to admit, i have a point. But, first things first. I will concentrate on WordPress, since, most of my readers are bloggers using the platform and many don’t really get why i nag all the time about performance and plugins. To give you a good taste of the complexity here is a small diagram.

wordpress

This actually is a rough representation of what’s going on when a client request on your blog is in progress. Let’s take it one step at a time:

  1. A client makes a request on your blog. This starts on the Apache level.
  2. Apache realizes that it’s a php script that has to be executed (index.php).
  3. Gives the PHP module the script as a parameter and kicks it off.
  4. Then, it’s WordPress’s time. It starts loading the core.
  5. On various steps of the process of rendering the requested page the plugins are loaded.
  6. Just like a special plugin, the theme of the site is loaded as well. WordPress decides if it needs to load single.php for instance (when rendering a single post) or index.php (when rendering the homepage) etc.
  7. Each time a plugin or a theme wants to make a query it uses the wpdb global variable. This actually channels the query through WordPress, which channels it to the PHP module, which channels it to the PHP MySQL module, which channels it to MySQL server, which runs the query and creates the result set, which is finally channeled back all the way to the plugin.

Do you see how painful it is to make a query? Now take that and multiply it by 50-60 which is the average query count on a WordPress blog (not the default installation but an established one). You can see now how your memory and CPU get clogged up when a few requests come along together.

(more…)

Get rid of the newsflash plugins. Do it yourself!

Does the title ring a bell? I bet it does. It must remind you of the article i wrote quite some time ago titled “Get rid of the sociable plugins. Do it yourself!“. It helped a lot of people save some CPU time and memory usage. Now it’s time for the newsflash! The idea came to me after i read this article on a modification for the theme. It actually gives a very nice little admin area on the theme options but it fiddles with the database so i decided to show you how you can do the same thing without any query run.

Firstly, i will summarize all the steps we are going to take in order to achieve this:

  1. We will have a plain text file called “newsflash.txt” in our theme folder. This file will actually contain the newsflash we want to display to the visitor. If it’s empty, or not there at all then nothing will be shown.
  2. On the “index.php” file of our theme we will be adding a few extra lines of code that will actually do just that. Check for the existence of the file and if it’s there and has things in it, then a newsflash div will be rendered before the posts do.
  3. Skin the newsflash div box through the style.css file.

The result will look something like the following.

newsflash

(more…)

Insert the post title in your “read more” tag easily

Watching twitter today, i came across a tweet from Kikolani. Now i’ve been following her for quite some time getting valuable feedback and post ideas. Today’s tweet was about a post on TechJaws called “The Biggest Mistakes in SEO” which i found interesting. As always i have my agrees and disagrees but still it was a nice read. One of the author’s points was ““Click Here” or “Read More” Link Anchor Text“. Here is what he suggests:

Many people use “Clíck here” or “Learn more” as the linking text. This is great if you want to be ranked high for “Click Here”. [...] It’s much more descriptive (and relevant) to say “learn more about {keyword topic}”

I see the point on this and i agree. Besides, the info has already been retrieved from the database so no more extra load is going down. It’s not only SEO friendly, it’s reader friendly as well. That’s what’s most important. On the comments, Kikolani said she hadn’t figured out how to do it. I thought that many non techy people out there might find it hard, as well. So, here is how i did it! (notice it on the read more following)

(more…)

101 Sociable links for manual insertion in WordPress

A few months back i had a post about how to get rid of your sociable plugins and doing the same thing by editing your theme. In that post i have included a few popular sociable networks such as Digg and Stumbleuppon but today i have decided to include as much as possible, 101 to be exact. You can go through them and decide which ones you want to use. The links are included as they should be in your theme. Take a look at the older post on how to do it and get the links from here.

I used the Sociable plugin source code to extract the links. You can also find images for the links herein here (also from the same plugin): 101 Sociable images (420) - 82.18 KB

As an example of how to use it, here is one with Digg:

  1. <a href="http://digg.com/submit?phase=2&amp;url=<?= the_permalink();?>&amp;title=<?= the_title();?>">Digg</a>

For more details please check out the older post. So here we go!

(more…)

Code efficiency and Javascript in WordPress

windmill_efficiencyYou all must know me by now. I am always nagging you about code efficiency, using minimum plugins and other improvement tactics. The past couple of days there has been some interesting conversation and feedback on Kim’s blog, on the post she made a few months back asking for plugin ideas for me to code. From there the idea for the YAFootnotes and My Tag Cloud plugins have been given plus some valuable feedback. Now, there is another conversation started from a user, Richard. My reply to all his valuable feedback would a) be too long for a comment and b) illustrates what i think might help some other people too. So, i decided to go on with this blog post. Enough with the chit chat, let’s see what he says.

(more…)

« Previous Entries