Random Content Based on Date Using PHP

Like most Web Designers, I like to put a small design credit link on the bottom of sites I build. I’ve got some work out of doing this in the past so it seems like a useful thing to do. Apparently there’s a reasonable amount of people out there that will have a look for a credit link if they like the look of the site and need one themselves. Trouble is, with 100’s of sites built and the same footer code added manually to each one, what if I wanted to change the credit text or link? I’d have to manually change it for every site!

Another thing to think about is the amount of websites I have of my own that could benefit from some good backlinks with good anchor text from clients sites. I’ve got one main site (this one!) but a whole pile of other ones that have a decent precence online that I can be contacted through, ie – my Twitter, Facebook & Linkedin accounts, other domains I own etc..

What I’ve done is add a small bit of PHP code to each client site footer that calls content from a single file on my own site/hosting. This means that if I want to change my footer link on 100’s of different sites, I can do it in just one place and they all get updated automatically! In that file I’ve got some more PHP code that shows different anchor text linking to my different websites based on what month of the year it is. Doing this automatically keeps the credit link fresh and dynamic and has the added benefit of showing you via Analytics which month/link was most effective in driving visitors to your sites.

I’m no PHP expert so the following code maybe easily improved upon by those who know more. If anyone has suggestions on how to improve, clean up or expand on this basic idea, please leave a comment below!

Here’s sample code for each website footer:
[php]<?php $reverb = file_get_contents(‘http://www.yourdomain.com/footer-credit.php&#8217;); echo $reverb; ?>[/php]

Here’s sample code for showing different content based on the month of the year:

if ($d=="Jan") {
echo "site by <a href=’http://www.reverbstudios.ie’>Reverb Studios Design Leitrim</a>";
} elseif ($d=="Feb") {
echo "site by <a href=’http://www.reverbstudios.ie/web-design/>Reverb Studios Web Design</a>";
} elseif ($d=="Mar") {
echo "site by <a href=’http://www.webdesignleitrim.ie’>Web Design Leitrim</a>";
} elseif ($d=="Apr") {
echo "site by <a href=’http://twitter.com/reverbstudios’>Twitter.com/ReverbStudios</a>&quot;;
} elseif ($d=="May") {
echo "site by <a href=’http://www.facebook.com/ReverbStudiosDesign’>Facebook.com/ReverbStudiosDesig</a>&quot;;
} elseif ($d=="Jun") {
echo "site by <a href=’http://www.linkedin.com/in/reverbstudios’>Linkedin.com/ReverbStudios</a>&quot;;
} elseif ($d=="Jul") {
echo "site by <a href=’http://www.reverbstudios.ie/prices/’>Reverb Studios Design</a>";
} elseif ($d=="Aug") {
echo "site by <a href=’http://www.reverbstudios.ie/contact-me/’>Reverb Studios Digital Desig</a>";
} elseif ($d=="Sep") {
echo "site by <a href=’http://www.reverbstudios.ie/testimonials/’>Reverb Studios Multimedia</a>";
} elseif ($d=="Oct") {
echo "site by <a href=’http://www.reverbstudios.ie/blog/’>Reverb Studios IT</a>";
} elseif ($d=="Nov") {
echo "site by <a href=’http://www.reverbstudios.ie/recent-projects/’>Reverb Studios Leitrim</a>";
} elseif ($d=="Dec") {
echo "site by <a href=’http://www.reverbstudios.ie/latest-news/’>Wordpress Web Design</a>";
} else {
echo "site by <a href=’http://www.reverbstudios.ie’>Reverb Studios Design</a>";

Credit to @barryflood for the Date idea.


Published by

Leon Quinn

Multimedia Design company in Leitrim, Ireland specializing in WordPress Website Design, Photoshop and Graphics. www.reverbstudios.ie

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.