[Resolved] Page Header not showing in archives

Home Forums Support [Resolved] Page Header not showing in archives

Home Forums Support Page Header not showing in archives

  • This topic has 5 replies, 2 voices, and was last updated 6 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #537845
    Thomas

    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

    #537933
    Tom
    Lead Developer
    Lead Developer

    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;
    } );
    #538002
    Thomas

    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

    #538237
    Tom
    Lead Developer
    Lead Developer

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

    #538293
    Thomas

    Yes, it works – thanks for the support

    #538770
    Tom
    Lead Developer
    Lead Developer

    Awesome, no problem ๐Ÿ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.