Archived topic
Move archive title and description to page header
5 replies · Started by Fabien on October 24, 2020
Hi,
Using php function and template files, I've created a full width header for my categories pages.
However, the title/description is now displayed 2 times in the page : in the header and in #content. I want to my title / description to be displayed only in the full width header.
Using this function works but it removes the title/description everywhere :
add_action( 'wp', function() {
if ( is_category() ) {
remove_action( 'generate_archive_title', 'generate_archive_title' );
}
if ( is_category() ) {
add_action( 'generate_after_main_content', 'generate_do_archive_description' );
}
} );
What should I do ? Stop using <?php do_action('generate_archive_title'); ?> in my header template ?
Thanks
Hi there,
You'll need to update your conditional logic to only apply to the template that you've added your header to.
Have you considered using our Header Element? It will remove the default archive titles if you use {{post_title}}: https://docs.generatepress.com/article/header-element-overview/
Thanks Tom. For now I'd like to keep my workflow (with version control) ;-)
In that case, your best bet is to update your conditions when removing the title to only apply to the necessary pages.
Will do, thanks again and keep the great work !
No problem! :)