Title: Child Theme Header.php
Last modified: August 20, 2016

---

# Child Theme Header.php

 *  [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/)
 * I have created a child theme and add a style.css file which imports the script
   from the parent file and then I made changes within that child style.css file.
 * Here’s the code:
 * /*
    Theme Name: KarmaChild Description: Child Theme for Karma Author: Kristian
   Bowman Template: Karma Version: 1.0 */
 * [@import](https://wordpress.org/support/users/import/) url(“../Karma/style.css”);
 * /* Change Post Title size and font style to italic */
    .home-banner-main h2 {
   color:#222!important; font-size:1.8em!important; font-style:italic; padding-bottom:
   5px!important; font-weight:400!important; }
 * This approach works and is simple and concise.
 * I tried the same approach with header.php file but without success:
 * /*
    Theme Name: KarmaChild Description: Child Theme for Karma Author: Kristian
   Bowman Template: Karma Version: 1.0 */
 * [@import](https://wordpress.org/support/users/import/) url(“../Karma/header.php”);
 * I have managed to take an exact copy of the parent header.php and edit the child
   version successfully but I was wondering can I use the [@import](https://wordpress.org/support/users/import/)
   functionality in the same way I have with the style.css file?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818757)
 * [http://codex.wordpress.org/Child_Themes](http://codex.wordpress.org/Child_Themes)
 * you need to create a copy of header.php in the child theme, possibly using [**ftp **](http://codex.wordpress.org/FTP_Clients).
 * [http://codex.wordpress.org/Child_Themes#Template_files](http://codex.wordpress.org/Child_Themes#Template_files)
 *  Thread Starter [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818796)
 * I have already read these help references. Like I say, I’ve successfully created
   a copy of header.php in the child theme and edited that but I was hoping to use
   the [@import](https://wordpress.org/support/users/import/) functionality in a
   similar way to the style.css methodology.
 * Can anyone advise if this is possible and if so how?
 *  [Frumph](https://wordpress.org/support/users/frumph/)
 * (@frumph)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818800)
 * The method you are describing is not advisable to import the functions from the
   parent theme header.php into the child theme’s header.php.
 * You could use an “include” or “require_once(‘../../maintheme/
 * But completely and utterly advising you not to, it’s bad mojo.
 *  Thread Starter [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818975)
 * Ok.
 * It may help if I explain why I’m wanting to do this.
    I need to prevent right
   click (copy image) on my site, I’ve been provided a piece of script which I can
   change in the header.php file (which works).
 * I’ve been advised to use a child theme to make changes :
    a) so I don’t break
   the master file b) so the script changes aren’t overwritten when I upgrade the
   theme etc
 * If there are other, safer, easier ways to do this then I’m all ears.
 *  [Frumph](https://wordpress.org/support/users/frumph/)
 * (@frumph)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818976)
 * is it a .js file you add the link to, or is just <script> </script> style
 * I ask because there are multiple methods to do this..
 * and yes, basically the advice they’re giving you is copy the header.php to the
   child theme and edit that header.php in the child theme.
 * However, if it’s a .js file you can ‘enqueue’ it from the child themes function.
   php file which would be better all around.
 * Got a pastebin for that code?
 *  Thread Starter [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818980)
 * Ok – that’s where I’d got to – I’ve taken a copy of the header.php file and then
   changed script in the Child header.php file as follows:
 * Replace
    <body <?php body_class(); ?>>
 * with
    <body onload=”;init_start(); ” id=”bodytag” class=”bodyContent” oncontextmenu
   =”return false;” <?php body_class(); ?>>
 * I may be wrong but i think that protects the parent header.php but means I’d 
   still have to repeat that process of copying and editing the child theme file
   every time I upgrade the theme right?
 * I am happy to try and use a js.file if this possible a better way.
    I’ve no idea
   how to do this.
 * sorry – I don’t know what a paste bin is.
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818981)
 * Putting aside the fact that those scripts are not effective and tick off your
   readers… I _think_ you may be going about this the wrong way.
 * If all you want to do is insert some javascript into the head section of your
   child theme, then consider this plugin.
 * [http://wordpress.org/extend/plugins/header-footer/](http://wordpress.org/extend/plugins/header-footer/)
 * That will let you insert what you want and you won’t have to maintain a copy 
   of the `header.php` file.
 * **Edit:** Oh, and [Pastebin.com](http://pastebin.com/) is a magical place where
   you can share code and even get _line numbers_. 🙂 Give it a try, it’s easy to
   use.
 *  Thread Starter [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818985)
 * All I want to do is prevent readers from right clicking and copying images, being
   a professional photographer it is imperative to protect my images. I want to 
   do so in a way that means I don’t have to keep on changing code every time I 
   upgrade the Theme version.
 * I read link Re: Header-footer plugins, will this do what I want?
    If so is there
   a particular one you;d recommend?
 * FYI – I’m using the Karma theme.
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818987)
 * > All I want to do is prevent readers from right clicking and copying images,
   > being a professional photographer it is imperative to protect my images. I 
   > want to do so in a way that means I don’t have to keep on changing code every
   > time I upgrade the Theme version.
 * I have been there before, but how do you prevent them from
    - “Print Screen” and paste into paint
    - screen grab products like Snagit,
    - “file save page as”
    - website download software will download the images
    - the Snipping Tool?
    - view page source and get the image link
 * Would it stop the FireFox AddOns:
    [Image Toolbar](https://addons.mozilla.org/en-US/firefox/addon/image-toolbar/)
   [Image Download](https://addons.mozilla.org/en-US/firefox/addon/image-download/)
   Would it stop [Harvesting Software](http://blog.outwit.com/?p=41).
 * Look at all the ‘stock image websites’ if there was a way to stop someone making
   a copy they would have used it.
 * You would also need to consider accessibility and disability options where the
   right mouse key could be mapped to a different action.
 * The only viable universal way I found was to create and upload a composite image,
   a low resolution minimum sized image and added a watermark.
 * Most graphic packages will have a batch action for this, accept that **this is
   the internet**, _if it is there it will get copied one way or another!_
 * The time I spent trying to prevent a right click could have been much better 
   spent on my creative photography, after a lot of testing it was only adding a
   watermark that worked, accepting that the watermarked image could be downloaded
   and cropped.
 * > TinEye is constantly crawling the web and updating our image database regularly.
   > We also accept direct contributions of complete online image collections. To
   > date, TinEye has indexed 2,163,266,343 images from the web. We add tens of 
   > millions of new images to TinEye every month, and our index is on the grow.
 * If someone likes your little image and downloaded it for personal use then is
   it a big issue, for image abuse there is also [Tineye](http://www.tineye.com/)
   that might find your images if they are used on the web, this is what some of
   the big stock website use to find [where an image is used](http://www.tineye.com/search/157a492f139f829719feb23408e18a6bba6b6be5/?pluginver=).
 * HTH
 * David
 *  [Frumph](https://wordpress.org/support/users/frumph/)
 * (@frumph)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818989)
 * Watermarks are your friend, big huge ones that display on the images, and for
   people to purchase the image they get the ones without it.
 *  Thread Starter [Katsura](https://wordpress.org/support/users/katsura/)
 * (@katsura)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2818997)
 * I’m guessing from you indirect response that the plugins don’t function as desired.
 * I’m VERY familiar with watermarks. Watermarks are suitable when providing a portfolio
   of a shoot to a client but are inappropriate for website general gallery/viewing
   purposes.
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2819000)
 * > I’m VERY familiar with watermarks. Watermarks are suitable when providing a
   > portfolio of a shoot to a client but are inappropriate for website general 
   > gallery/viewing purposes.
 * Watermarks are an acceptable way of presenting any media where you want to protect
   your IP and copyright, website mockups are presented to blue chip companies with
   watermarked composite images inserted.
 * Just ‘disable the right mouse click’ will not stop anyone from grabbing the images,
   if someone wants a copy there are a large number of ways to get it, and as Jan
   said:
 * > those scripts are not effective and tick off your readers… I think you may 
   > be going about this the wrong way.
 * The right way is just to minimise the risk, only display an image on the internet
   if you are prepared for some copies being made as you cannot prevent it.
 * Minimise the infringement risk, only upload a low resolution image at a fixed
   size for the website, with or without a watermark.
 * If your clients are visiting the website and you think they might grab a copy
   then you could put up a small clean thumbnail linked to a larger watermarked 
   image.
 * Maybe an over reaction as there are billions upon billions of images on the internet,
   the chances of someone visiting and stealing an image are minute and a risk you
   have to take, if you want to have your portfolio online.
 * **Ideas:**
    Looking at websites for top photograpers they seem to use flash or
   sprite scripts.
 * Have a look to see if ther is a sprite plugin or script, something that would
   chop the image into little pieces and rebuild it on the page.
 * Splice the image yourself say sixteen bits, then upload it to the post and rebuild
   it in the content, a lot of work though.
 * David

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

The topic ‘Child Theme Header.php’ is closed to new replies.

 * 12 replies
 * 5 participants
 * Last reply from: [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/child-theme-headerphp/#post-2819000)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
