Archived topic
Allow overrides for functions
23 replies · Started by Sunil on November 6, 2016
Ah, good idea! :)
Hey Tom, I'm back, realizing that I'm going to want header images on search page, 404 page, Events Calendar page, etc - views that don't have a page in WP to set that. Any ideas for these kinds of pages?
You would need to set them up using a function for now:
add_action( 'generate_after_header','tu_search_page_header' );
function tu_search_page_header() {
if ( ! is_search() ) {
return;
}
?>
Your Page Header HTML (can copy from the source of another page and adjust the text)
<?php
}
add_action( 'generate_after_header','tu_404_page_header' );
function tu_404_page_header() {
if ( ! is_404() ) {
return;
}
?>
Your Page Header HTML (can copy from the source of another page and adjust the text)
<?php
}
There's a few different conditionals for events calendar depending on what you need: https://gist.github.com/jo-snips/2415009
Hi Tom, thanks for the hook. In my theme I'm showing the header image inside the article. Is there a hook to put custom HTML after this?
<article id="post-139" class="post-139 page type-page status-publish" itemtype='http://schema.org/CreativeWork' itemscope='itemscope'>
<div class="inside-article">
Try changing: generate_after_header
To: generate_before_content
Great, thanks! That's just what I need for the 404 page and probably events pages too.
On the search page, it repeats the header for each result found, and doesn't display the header at the top (so no option to just display the first instance. Any ideas? Here's the page it appears: http://dev.ncbirthcenter.org/?s=test
Ah right, looped posts have that hook before the content of each post.
Try this hook instead: https://docs.generatepress.com/article/generate_before_main_content/
Yes, that does it! Thank you!
You're welcome :)