WordPress twenty seventeen different header images in different pages

spam blockers

Came across the challenge of having to customise the WordPress Twentyseventeen theme to cater for header images that match content of specific pages, let’s say, for example that one has a WP site with portraits of different animals in various pages of the site, whilst twenty seventeen theme allows you to upload a serie of header images that can be randomly rotated on the pages as the are loaded by the end user it does not specifically allow to have the same system dedicated to each pages. The following example remedies this.

After digging a bit and following some other posts on the web, here are the steps required to enable this feat.

Note that you must be able to edit the PHP files and thus be proficient in editing PHP and be familiar with WP inner workings…

First edit the wp-content/themes/twentyseventeen/header.php

(make a backup first!):

...

<div id="page" class="site">
 <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentyseventeen' ); ?></a>

<header id="masthead" class="site-header" role="banner">

<?php get_template_part( 'template-parts/header/header', 'image' ); ?>

 <?php if ( has_nav_menu( 'top' ) ) : ?>
 <div class="navigation-top">
 <div class="wrap">
 <?php get_template_part( 'template-parts/navigation/navigation', 'top' ); ?>
 </div><!-- .wrap -->
 </div><!-- .navigation-top -->
 <?php endif; ?>
</header><!-- #masthead -->

...

Remove or comment out the orange line and replace with the following code.

...

<div id="page" class="site">
 <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentyseventeen' ); ?></a>

<header id="masthead" class="site-header" role="banner">

<?php
// start simply copy header-image.php to header-dog.php and mod the file accordingly
if(is_page("dog-paintings-and-dog-portraits")) {

get_template_part( 'template-parts/header/header', 'dog' );

}
else{

get_template_part( 'template-parts/header/header', 'image' );

}
// end mod
 ?>

<?php if ( has_nav_menu( 'top' ) ) : ?>
 <div class="navigation-top">
 <div class="wrap">
 <?php get_template_part( 'template-parts/navigation/navigation', 'top' ); ?>
 </div><!-- .wrap -->
 </div><!-- .navigation-top -->
 <?php endif; ?>

...

in the example above the page is called

dog-paintings-and-dog-portraits

The header file called is called header-dog.php under the wp-content/themes/twentyseventeen/template-parts/header/ folder (which is a copy of the header-image.php and edited to deal with the other images)

if there are more than one page, simply add more conditionals ifs for each individual pages and copy header-image.php to match like above.

More to come as I write the code…

How Exciting!

Just added a new Plugin on this Blog to enable me to be more creative. I am still experiencing with it. I am glad to see that one of the biggest issues with CMS systems is still their level of complexity.

The most important barrier to past, modern and future technologies is simplicity and foremost usability and ability to remember how it works. In 2001 that was when I saw a website called Superupdate, now Hannon Hill advertising their CMS, I looked into it, it was relatively simple. So I though, I can easily do that even easier and simpler and created my own CMS system A very simple system, so simple that It is for people that are barely able to use Computers at all. Most of these people being the mature generation,

This is not a problem for things that you’re using all the time like Smart phones (well how much do you actually know about the phone you’re using? Do you know for example it’s got a feature allowing you to make phone calls). It’s more like when you tend to not do it often and you’re not an Internet Guru, let alone a PC wiz kid. For most people having or managing a website is not necessarily something they do on a full time basis. like the chairman of a Club or a charity or a one man business. That is my target market. My website design site provides an unique design plus the ability to edit the pages easily and fast without having to hold a degree in Computing Science. My clients only contact me when they need technical assistance, it works because it is KISS.

WordPress

This CMS system is quite good I must say, (the one that I used to create this content.), it is relatively simple, the strategy is working great especially the Plug-In system, although I must say that I struggle, it’s getting too complicated for me already.

How Exciting?

Now the reason, finally, of my excitement is that when you are using WordPress you tend get a lot of spam messages (well this site does). I am happy to announce that on this front there’s  been a development, with the use of a Plug-in called Spam-stopper which is the easiest one ever. I have yet to receive a single spam comments 🙂 or any comments at all for that matter.