Site logo

Archived topic

Page Header not showing in archives

5 replies · Started by Thomas on April 1, 2018

Viewing posts 1–6 of 6

Hi,

I've configure a page header for all pages of my site, and it shows in every page - except the archives. I've set the page header in "Global Locations" for every entry, on the archives it does not show up.

It works for example on /category/aktuelles/

But it does not work for example on /2018/03/

I did not find any place else to set the page header - have I missed something?

thanks and br,
__
/homas

Date archives currently aren't supported in the Global Locations area.

However, you can use a function to apply it:

add_filter( 'generate_page_header_id', function( $id ) {
	if ( is_archive() ) {
	 	return 17686; // ID of the Page Header to use.
	}
  
  	return $id;
} );

Hi,

thanks for the quick reply, works like a charm :-)

Since this snippet makes the page header hardcoded, I'm trying to make the page header for the date archive pages the same as the page header for anoter "global location" (e.g. the category archive pages).

I'm not really very much into WordPress Coding, so with looking into the source of the plugin I came up with the following solution:

add_filter( 'generate_page_header_id', function( $id ) {
    if ( is_archive() ) {
        $global_locations = get_option( 'generate_page_header_global_locations' );
        return $global_locations[ 'category' ];
    }
    return $id;
} );

which I've put into the functions.php for my custom child theme.

At first sight it looks ok, but I've no idea if there are any drawbacks/problems with this solution - any comments?

br,
__
/homas

That should work - did you try it? Any issues?

Yes, it works - thanks for the support

Awesome, no problem :)

This archived topic is closed to new replies.