Title: Headers for posts?
Last modified: August 18, 2016

---

# Headers for posts?

 *  [MrM](https://wordpress.org/support/users/mrm/)
 * (@mrm)
 * [21 years ago](https://wordpress.org/support/topic/headers-for-posts/)
 * I’d like to be able use images as headers to my posts, according to which day
   the post was made. For example, a post made on Monday would have the graphic 
   for Monday as the header and so forth.
 * Problem being I’m an absolute PHP noob. After much searching and hacking I’ve
   been able to get as far as getting an image posted according to the day. However,
   it looks at todays date and not the date the post was made. Thus all my posts
   have the same header, regardless of the day they were made and it changes everyday.
   I told you I was a noob! Here is the code below:
 * <?php
    $date=date(“D”); if ($date==”Mon”) echo'<img src=”images/mon.gif” />’;
   if ($date==”Tue”) echo'<img src=”images/tues.gif” />’; (and so forth) ?>
 * My question is how do I get it so the header images corresponds with the day 
   the post was made and stays that way? Any help would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years ago](https://wordpress.org/support/topic/headers-for-posts/#post-207404)
 * If you made sure to use three letter days for your graphics (i.e. tue.gif instead
   of tues.gif), you can shorten your code:
 * `<?php
    $date=strtolower(the_date('D', '', '', false)); echo "<img src="images/
   $date.gif" />"; ?>
 * If you want it for all posts, or need to use `the_date()` to…display the date,
   try:
 * `<?php
    $date=strtolower(get_the_time('D')); echo "<img src="images/$date.gif"/
   >"; ?>
 *  Thread Starter [MrM](https://wordpress.org/support/users/mrm/)
 * (@mrm)
 * [21 years ago](https://wordpress.org/support/topic/headers-for-posts/#post-207420)
 * Hmmm, doesn’t seem to want to work for me. I’m just getting parse errors.
 * Whilst playing around I seem to have come slightly closer. I tried the following:
 * <?php
    $date=the_time(“D”); if ($date==”Mon”) echo'<img src=”/images/mon.gif”/
   >’; (repeat for the rest of the week) ?> (I will use your recommendation about
   shortening the code Kafka, thank you)
 * I’m now getting the day the post was created being outputted but not the corresponding
   image file. So I’m just ‘Mon’ in the header instead of mon.gif…anybody know why?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years ago](https://wordpress.org/support/topic/headers-for-posts/#post-207421)
 * `$date=get_the_time('D')`
 * `the_time()` will display the info (which makes it difficult to assign to a variable),
   where `get_the_time()` merely returns it.
 *  Thread Starter [MrM](https://wordpress.org/support/users/mrm/)
 * (@mrm)
 * [21 years ago](https://wordpress.org/support/topic/headers-for-posts/#post-207422)
 * AAahhh, it was” $date=get_the_time(“D”);” like Kafka said, not “$date=the_time(“
   D”);” like the PHP noob MrM said!
 * Edit: beat to it! Thank you for your help.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Headers for posts?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [MrM](https://wordpress.org/support/users/mrm/)
 * Last activity: [21 years ago](https://wordpress.org/support/topic/headers-for-posts/#post-207422)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
