I wanted to keep track of the Alexa ranking for my blog without having to constantly visit the Alexa site. I found a plugin for this called Alexa Rank, but the plugin shows a graphical bar that you have to hover over to get the numerical value. I wanted something a bit more simple that I could better integrate into my layout (I just display the text in a list of administrative options other users don’t see). So, I hacked something together that does the job for me, maybe someone else is looking for the same type of thing.
I used class_http.php to grab the information from Alexa, and it caches the info for 1 day (the plugin only polls Alexa once per day, if it polled on every page load, a busy site would probably end up getting banned). The rank that is displayed is linked back to the Alexa page for the URL that is being ranked.
Installation
To install the plugin, create a directory called ‘jpf_rank’ in your plugins folder. Extract jpf_alexa_rank.zip and copy all of the files to the jpf_rank directory. If you’ve already installed any of my other ranking plugins, then you only need to copy the jpf_alexa_rank.php file to the jpf_rank directory. Go to your Manage Plugins page and activate the plugin and you’re ready to go.
Configuration
To display your Alexa rank, insert the following code wherever you want to see the rank:
<?php jpf_alexa_rank(); ?>
The default settings assume you’re putting this in your sidebar, so it wraps the result in <li> and </li> which will display like this:
{Note that I’m not running this plugin anymore, so there is no display here}
If you’d like it formatted differently, here are the available parameters:
- $before = what you want to appear before the rank number. The default is ‘<li>Alexa: ‘.
- $blog = the URL to get the rank for. By default, the ‘home’ setting that you set in your Wordpress general settings page is used. You can enter a different one if you prefer (eg. http://sojoe.info/downloads).
- $after = what you want to appear after the rank number. The default is ‘</li>’.
Examples
If you just want to display the rank number inline with other text, like this: {Note that I’m not running this plugin anymore, so there is no display here}, use the following:
<?php jpf_alexa_rank (”,”,”); ?>
Size: 5,00 kBytes
FileType: .zip-File
Edited on 03. Mar 2007 - 15:46 h
Downloads: 731
Free for visitors






November 20th, 2006 at 2:11 pm
Version 1.0.1 is now available. It does two things:
1. Typing your own URL in didn’t work, should now be fixed
2. If you want more than one URL rank on your site, you’ll have to disable the cache. To do this, in the jpf_alexa_rank.php file delete line 21 (has a comment following it saying you should delete that line), and uncomment the following line by deleting the two slashes. This will disable the cache so you should be able to call multiple times with different URIs. Let me know if you have any issues.
April 26th, 2007 at 2:21 am
[...] Step 1: install JPF Alexa Rank Wordpress Plugin [...]
May 20th, 2007 at 2:58 am
[...] Visit [...]