Title: Changing theme each month.
Last modified: August 18, 2016

---

# Changing theme each month.

 *  [skernick](https://wordpress.org/support/users/skernick/)
 * (@skernick)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/changing-theme-each-month/)
 * Hello. I am a beginner at this and have run into a problem. I want to have a 
   unique banner appear at the top of each months posts. I have the theme heavily
   Frankesteined and I am afraid I have hit a wall. The site is [here](http://www.yankelovich.com/blog).
   I have the banner set up for November but as you can see, it sticks for every
   month. Any help would be havily appreciated. Thanks. -Sean

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

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/changing-theme-each-month/#post-660582)
 * “_I have the theme heavily Frankesteined_“
 * Hehe.
 * Here’s a little PHP to automate the image; place it somewhere before the image
   is displayed in your template:
 * `<?php $cur_month = strtolower(date('F')); ?>`
 * Then alter your ‘top banner’ code to:
 * `<div class="topbanner2"><img src="http://www.yankelovich.com/blog/images/<?php
   echo $cur_month; ?>/<?php echo $cur_month; ?>.jpg" border="0"></div>`
 * References:
    [http://php.net/date](http://php.net/date) [http://php.net/strtolower](http://php.net/strtolower)
 *  Thread Starter [skernick](https://wordpress.org/support/users/skernick/)
 * (@skernick)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/changing-theme-each-month/#post-660761)
 * Thanks so much for the reply. I am almost a complete novice with php. This works
   great but it misses my target a little. The banner image will change as the month
   does but what I need it to do is change when the user clicks on an archived month.
   This way the banner matches the month that they are viewing. If you have any 
   more assistance it would be incredibly helpful. Thanks so much.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/changing-theme-each-month/#post-660764)
 * “_what I need it to do is change when the user clicks on an archived month._“
 * You can get as complicated as you want with this. And if you don’t know PHP it**
   will get** complicated. But just trust me…
 * The only part we need to change is the initial one I provided:
 * `<?php $cur_month = strtolower(date('F')); ?>`
 * This is going to expand bit so we can properly decide what to assign $cur_month.
   The following hits *current* on the home page, but the archive’s month on archived
   query pages:
 *     ```
       <?php
       global $month, $wp_query;
       if( is_archive() ) {
       	$cur_month = strtolower($month[$wp_query->query['monthnum']]);
       } else {
       	$cur_month = strtolower(date('F'));
       }
       ?>
       ```
   
 * Let’s go over what’s happening here:
 * is_archive() is a WordPress [conditional tag](http://codex.wordpress.org/Conditional_Tags)
   that returns true if we’re on an archive page (i.e. posts for November 2007).
   When we are, we can access the archive month through `$wp_query->query['monthnum']`—
   however it’s only the numeric value, so we also have to pass it as an array key
   to the global variable $month (which hold the names of the months).
 * If we’re not on an archive page, the default is to use the current date (‘F’ 
   is a format character that tells it to only return the full text name for the
   month), as before.
 * For both, strtolower() is a PHP function which just returns any string it’s passed
   in all lowercase characters.
 * **_Now_**, if you’d like this to work with the current month, the archive’s month,
   and the month for a post when on a post’s permalink page:
 *     ```
       <?php
       global $month, $wp_query;
       if( is_archive() ) {
       	$cur_month = strtolower($month[$wp_query->query['monthnum']]);
       } elseif( is_single() ) {
       	$cur_month = strtolower($month[substr($wp_query->post->post_date, 5, 2)]);
       } else {
       	$cur_month = strtolower(date('F'));
       }
       ?>
       ```
   
 * The first and last if blocks are the same. The one we perform for is_single()(
   single post page) does something similar to the archive month, but collects the
   numeric month from the $post object’s post_date property ([substr()](http://php.net/substr)
   is another PHP function, this one letting us pick out the month from the post_date’s
   format of YYYY-MM-DD HH:MM:SS).

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

The topic ‘Changing theme each month.’ is closed to new replies.

## Tags

 * [Banners](https://wordpress.org/support/topic-tag/banners/)
 * [changing](https://wordpress.org/support/topic-tag/changing/)
 * [customized](https://wordpress.org/support/topic-tag/customized/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [image](https://wordpress.org/support/topic-tag/image/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/changing-theme-each-month/#post-660764)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
