Date specific header image in the Witcher World WordPress theme

Have you ever wanted to display specific images on certain dates in the header of your WordPress page like Google does?

If you want to automatically set the header image based on the date there is an easy way to do it. This way you can display a prepared image on certain dates like Independence Day, your birthday, or as in this example on the International Women’s Day, March 8th.

In the original Witcher World WordPress theme there are two ways to display header images: one selected image or a random image from multiple uploaded header images.

If you have access to your site via FTP and are not afraid of changing some PHP script in your Witcher World WordPress theme follow the simple steps below:

  • Upload a 988 pixel wide and 300 pixel high image to the “images” folder of the your Witcher World WordPress theme
    • Name the image “header_womens_day.jpg” (without the quotes)

wordpress witcherworld images folder

 

  • Log into your WordPress site as an administrator,
  • On the left side click “Appearance” and “Editor”,

wordpress appearance editor select

 

  • On the right side select “Header”,

wordpress theme header edit select

 

  • In the editor find the following line. That sets the header image of the theme.

<div id=”header”<?php if(get_header_image() != “”) echo ” style=’background-image: url(“.get_header_image().”);'”; ?>>

 

  • Replace it with the following script:

<div id=”header”
<?php
$today = date(“m-d”);
$templatedir = get_template_directory_uri();
$background_image_url = “”;
if ( “03-08″ == $today ) {
// Women’s day
$background_image_url = $templatedir.”/images/header_womens_day.jpg”;
} elseif (get_header_image() != “”) {
$background_image_url = get_header_image();
}
echo ” style=’background-image: url(“.$background_image_url.”);'”;
?>
>

 

  • At the bottom of the page click the “Update File” button

wordpress theme edit update file button

 

On every March 8th the “header_womens_day.jpg” image will be your header image. The  date(“m-d”) function returns the month and day in the  UTC time zone, so you will only see the change when it is March 8th in London (8 hours ahead of Los Angeles).

 

Where are the uploaded images stored in WordPress?

When you upload an image for a page or a post WordPress stores the image at the following location:

wp-content\uploads\YEAR\MONTH

where YEAR and MONTH are the year and month of the upload date.

wordpress image upload location

WordPress creates a new folder every month to reduce the number of files per folder. This way you can find your files easier and the server can also find the files faster, because it can work with a smaller list of directory entries.

How can I create a custom header image for the Witcher World theme in WordPress?

The Witcher World is a great theme and it is very easy to customize it. The original header image is beautiful, but if you want to display your custom header image you have to take some simple image editing steps to make sure it looks as good as the original.

The original image contains the left and right borders of the header, so if you add your image you have to add those to your custom image.

Create the custom header image

Click the image below to open the header image template with transparent areas for your custom image in a new tab of your web browser. On the new tab right click the image and select “Save image as…” (“Save picture as…” in Internet Explorer) and save the image to your computer. When it is done close  the new tab to return to this page.

Witcher World header transparent template

 

Select a picture on your computer that you want to use as the header image. The following steps show how to do it in Colrel Paintshop Pro XI. All other graphics editor programs should have similar feature to do the same.

  • To resize the image to 988 pixel wide select “Resize” in the Image menu

Paint Shop Pro Resize Select

  • Set the width to 988 pixels and check the “Lock aspect rato” to set the height automatically and avoid distortion, and click OK,

Paint Shop Pro Resize

  • In the View menu select “Zoom to 100%” to see the larger view of the image,

Paint Shop Pro Zoom To 100%

  • To crop the image to 988 wide  and 300 high on the left side select the crop icon and in the header enter 988 pixel width and 300 pixel height,

Paint Shop Pro Crop Select

  • Move the crop rectangle to the desired place and click the “Apply” button on the header,

Paint Shop Pro Crop

  • Set the background color to blue to enable the transparency during the paste of the template,

Paint Shop Pro Background Color Is Blue

  • Double click the background color indicator,

 Paint Shop Pro Background Color Select

    • Click the blue color and click OK,

Paint Shop Pro Background Color Blue

  • Open the Witcher_World_header_transparent_template.png in the same application,
  • In the Selections menu click “Select All”

PaintShopPro_SelectAll

  • In the Edit menu click “Copy”,

PaintShopPro_Copy

  • Switch to the cropped image by selecting the file in the Window menu,

Paint Shop Pro Window Menu

  • Paste the Witcher_World_header_transparent_template.png on top of it as a “Transparent selection” exactly on top of your cropped image,

Paint Shop Pro Paste Transparent Selection

  • Save the new composite image on your computer. Click Yes to allow Paint Shop Pro to merge the parts of the image.

PaintShopPro_SaveMerge

Upload the custom header image

  • Log into your WordPress site as administrator,
  • On the left side select “Appearance,” and “Header”,

WordPress Theme Header Change Select

  • On the middle pane in the Select Image section select “Choose File” under Choose an image from your computer,

WordPress_ThemeHeaderChangeChooseFile

  • Select the new file and click the Open button,

WordPress Theme Header Change Browse File

  • Click the “Upload” button on the page,

WordPress Theme Header Change Upload File

  • You can upload multiple images and select  “Random: Show a different image on each page” in the Uploaded Images section to display a different image at every page load.

WordPress Theme Header Change Random

  • Click the “Save Changes” button at the bottom of the page.

WordPress Theme Header Change Save Changes