Customize Date Image

Posted by

Customize Date Image

You can place your own image for WordPress Date instead of one already available in the theme. Follow the instruction below:

  1. Create your own date image template in Photoshop.
  2. Using the ruler guide in Photoshop, slice the template into three parts.
  3. You will need to determine the date format you use in your blog.
  4. Now create individual images using the sliced template and name them accordingly. For day of week, the naming convention is mon.gif, tue.gif, … sun.gif; for the day – 1.gif,… 30.gif; for the month – jan.gif, feb.gif,… dec.gif.
  5. Create a folder called wp-images and upload these images in this folder.
  6. Now, go to your WP theme folder and look for the post.php file and open it for editing. Check again, you may also need to edit the index.php file.
  7. Look for the date function as such:

< ?php the_time(‘D, M j’) ?>

Now break that into 3 parts like this:

< ?php the_time(‘D’) ?>
< ?php the_time(‘M’) ?>
< ?php the_time(‘j’) ?>

Now we edit them so the code echos the image equivalent:

< ?php $d = strtolower(get_the_time(‘D’)); echo (“< img src= ‘wp-images/{$d}.gif’ > “); ?>
< ?php $m = strtolower(get_the_time(‘M’)); echo (“< img src= ‘wp-images/{$m}.gif’ > “); ?>
< ?php $j = strtolower(get_the_time(‘j’)); echo (“< img src = ‘wp-images/{$j}.gif’ > “); ?>

Leave a Reply

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