RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Display a Different Image Each Day with Shortcode

This snipped will display a different image for each day of the week. As pointless as it is, it was requested way back in the Internoetics days. Create an image as monday.jpg, tuesday.jpg, and so on.

1
<?php 
2
/*
3
 Display a Different Image Each Day of the Week with Shortcode
4
 http://www.beliefmedia.com/code/wp-snippets/day-image
5
*/
6
 
7
function beliefmedia_day_image($images = 'images/dir') {
8
 $today = strtolower(date('l'));
9
 return (file_exists($images . '/' . $today . '.jpg')) ? '<img width="50" height="50" src="' . $images . '/' . $today . '.jpg" border="0">' : 'No image was found for ' . $today;
10
}
11
add_shortcode('dayimage', 'beliefmedia_day_image');
12
 
13
/* Usage */
14
echo beliefmedia_day_image();

There's also a PHP function.

If you wanted to expand upon the code above, you could create all sorts of image combination effects.

1
$today = date('l'); // Day of week
2
$month = date('m'); // Month
3
$dweek = date('j'); // Day of the month without leading zeros - use "d" for a leading zero.

View the PHP manual for ideas on date usage.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment