Archived topic
Custom header in child theme
14 replies · Started by Alexander Babaev on August 13, 2018
Hello, dear developers!
Prehistory: I have a table:
<table>
<tr>
<td <?php if( wp_is_mobile() ){ ?> width=20% <?php } else { ?>width=10% height="100" <?php } ?> align="left">
<a href="/"><img src="/mylogo.png" alt="SITE TITLE" title="TO MAIN" <?php if( wp_is_mobile() ){ ?> width="50" height="50" <?php } else { ?>width="100" height="100" <?php } ?> border=0 /></a>
</td>
<td <?php if( wp_is_mobile() ){ ?>width="80%"<?php } else { ?>width="90%"<?php } ?> align="left">
<?php if( wp_is_mobile() ){ ?><span class="sitesubtitle_m"><?php } else {?><span class="sitesubtitle"><?php } ?>Subtitle</span>
<br>
<?php if( wp_is_mobile() ){ ?><span class="sitetitle_m"><?php } else {?><span class="sitetitle"><?php } ?>Site title</span>
</td>
</tr>
</table>
which I use as a website header. In Customizer I disabled the title and subtitle display, as well as all the logos, and insert the table into the GP HOOKS before header content. Today i want to disable GP Hooks and for replace logo i created GP child theme.
Problem: Which file and how should I replace it so that the table is displayed correctly?
Hi there,
Not quite sure if I understand.
Are you looking to add hooks using a function?
https://docs.generatepress.com/article/using-hooks/
Let me know if this helps :)
Are you looking to add hooks using a function?
https://docs.generatepress.com/article/using-hooks/
Yes, but in theme file or plugin. Not in GP Hooks (i want to disable executing php on web editor)
I heard that GP Premium 1.7 is coming out soon with the updated Page Haders. Will there be an opportunity to write your own title with an unidentified logo and the name of the site in the Site Identity?
Sorry I might be misunderstanding something here.
You can definitely use GP hooks without the hooks module (it will soon be replaced with Hooks Element by the way).
You just need to add the hooks using function method here:
https://docs.generatepress.com/article/using-hooks/#usage
And yes you can create plugins for those functions:
https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
I found a way (it seems). So in the functions.php file of child theme, I realized the idea:
add_action( 'generate_before_header','medcolthm_header' );
function medcolthm_header() { ?>
<table>
<tr>
<td <?php if( wp_is_mobile() ){ ?> width=20% <?php } else { ?>width=10% height="100" <?php } ?> align="left">
<a href="/"><img src="/mylogo.png" alt="SITE TITLE" title="TO MAIN" <?php if( wp_is_mobile() ){ ?> width="50" height="50" <?php } else { ?>width="100" height="100" <?php } ?> border=0 /></a>
</td>
<td <?php if( wp_is_mobile() ){ ?>width="80%"<?php } else { ?>width="90%"<?php } ?> align="left">
<?php if( wp_is_mobile() ){ ?><span class="sitesubtitle_m"><?php } else {?><span class="sitesubtitle"><?php } ?>Subtitle</span>
<br>
<?php if( wp_is_mobile() ){ ?><span class="sitetitle_m"><?php } else {?><span class="sitetitle"><?php } ?>Site title</span>
</td>
</tr>
</table>
<?php }
Is this the right decision or can I have problems later?
When GP 1.7 will realised, approximately?
Yup the before header hook is the way to go for this case and 1.7 (should be released today) won't help much :)
Same thing explained here:
https://docs.generatepress.com/article/split-header-three-sections/
Let me know if this helps :)
Let me know if this helps
Sorry, but not. It isnt work =(
Not sure what you mean.
This should be the right way:
https://generatepress.com/forums/topic/custom-header-in-child-theme/#post-647541
This should be the right way:
https://generatepress.com/forums/topic/custom-header-in-child-theme/#post-647541
I.e. I will not have problems afterwards (for example, after upgrading to 1.7)?
And another question: how to create a separate header for a particular page with this creation of the header?
No you will not have problem after when upgrading to 1.7.
To create a separate header using the same hook, you will need to use conditional tags:
https://docs.generatepress.com/article/using-hooks-conditional-tags/
Thanks! I have no question at this time!)
No problem :)