admin管理员组文章数量:1122846
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?
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?
Share Improve this question asked Sep 18, 2017 at 19:57 jedidesignerdjedidesignerd 112 bronze badges 2 |2 Answers
Reset to default 0Your 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.
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.
本文标签: How to duplicate a page template but make minor changes to the header
版权声明:本文标题:How to duplicate a page template but make minor changes to the header? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736286473a1927677.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
style.css
file that only needs to contain comments to tell WP this is a theme, and copy yourheader.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 Commented Sep 18, 2017 at 20:16