1

I will apologize in advance, I am very new to this. I have been teaching myself php as a hobby, but now I need it for work! I don't work as a web designer, but to try and save some money, I need to be able to make minor changes to our website.

I can handle most things... But this one issue is throwing me for a loop.

The page was designed by a "marketing firm" and the code is a mess. There's stuff that's old that the site isn't even using, but I am afraid to mess with that. It is making finding what I need to find, a bit difficult.

The header for the page has an image on it. I need to make a new page in addition to the one that is already created -- it's just a one page type website. I need to make a page for a locations map plug-in. I have everything working just fine... The new page is created, the locations map plug-in code is working, but I need to get rid of the header image! I can't find where I change the code.

I made a duplicate of the main page theme, and took out the bulk of what is on the main page. There's NOTHING for the header. When I go into the header.php file, I see where it needs to be changed, but if I duplicate it, give it a new name, and change the code to suit my needs, where in the code do I direct the new duplicate template page to pull that new duplicate header info?

Is this even possible?

  • 1
    Instead of editing the theme directly, you should create a child theme. Basically you create a new style.css file that only needs to contain comments to tell WP this is a theme, and copy your header.php file into the child theme. Then, use PHP conditionals around the header image - if(!is_page('no-image-page-slug')) { display the image, else display nothing or some text replacement if you like. – WebElaine Sep 18 '17 at 20:16
  • Definitely going to try this! – jedidesignerd Sep 18 '17 at 20:35
0

Your best bet is to rename the old header.php to header.bak.php and your new copy to header.php. header.php (there's only one such file, always) is called from the other theme templates using get_header(). What you could/eventually should do, if you don't want to directly edit the existing theme, is set up a child theme, copy over header.php to that child theme's directory, and edit it there. If the theme was custom-made and isn't going to be updated anyway, you might however skip that part. Just make sure there's a backup.

  • 1
    I am going to try to set up a child theme... I didn't even know that was a thing! I looked it up, and it looks like it's within the scope of my "expertise" – jedidesignerd Sep 18 '17 at 20:35
0

Create a child theme, in which you can create a new header file for your different page template as you want it to be.

Let us say your new header file is header-new.php. Now call this header file in your page template as get_header( 'new' ).

This is how you can have different header files for different templates and call the respective header files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.