Archive for the Category »Tips and Tricks «

Simple Banner Rotation in WordPress.

Have a wordpress blog and want to rotate some banners or photos?  Here is a quick and dirty way.

Go to wordpress.org and find a a widget that allows you to post PHP code.  Once you find one you like install it. You can then go to your ->Appearance ->widgets section.  I put the widget in my sidebar.  Once there you can click on the widget and it probably have a Title field which you can call it “Ads” or what ever you need.  Then it will have a text area where you can add some code.  There just put this in:


$bannerAd[1] = ‘<a href=”http://www.destinationlink/” target=”_BLANK”><img src=”/images/ad1.png”></a>’;

$bannerAd[2] = ‘<a href=”http://www.destinationlink/” target=”_BLANK”><img src=”/images/ad1.png”></a>’;

$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];


You can add more by just coping and pasting more of the “$banner….” block of code.  Don’t forget to increment the number that is in the [ ]’s.

Hope it helps!

Finding large files in Linux.

I have a couple of web servers and the disc keeps filling.  I know, manager them!  Here is a little trick to find the large offenders if you are going through the same thing.

# du -a /var | sort -n -r | head -n 10

That line will show you the top 10 largest file/directories is taking up the most space in a /var directory/file system.  If you want to search other directories, just modify the /var path to the path you wish to search.

Hope it helps someone!