[Resolved] Hide hero/header on specific pages

Home Forums Support [Resolved] Hide hero/header on specific pages

Home Forums Support Hide hero/header on specific pages

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1032468
    Steven

    Is there a way to configure things so the Page Hero header element that’s set to display on all pages is suppressed when the Disable Elements Featured Image / Page Header option is selected on a specific page? We’re trying to figure out how we can:

    1) Have a page hero display the featured image of a page by default when a featured image is added (this is working)
    2) Suppress the display of the hero but still have the featured image specified for the page for search result thumbnail reasons. We’ve tried selecting Disable Elements Featured Image / Page Header option on the page, but it doesn’t appear to hide the hero header element.
    3) Not have to specify each individual page in the exclude rules for the hero display config. We have a bunch of users and the option to disable the hero/header while creating/editing a page is needed.

    Should the Disable Elements Featured Image / Page Header option for the page be suppressing the hero element on the page?

    #1032869
    David
    Staff
    Customer Support

    Hi there,

    no – the disable featured image / page header won’t disable the Header Element. You could try this PHP snippet:

    add_filter( 'generate_header_element_display', function( $display, $element_id ) {
        if ( 123 === $element_id ) { // Only target specific Element
            if ( has_post_thumbnail() && get_post_meta( get_the_ID(), '_generate-disable-post-image', true ) === 'true' ) {
                $display = false;
            }
        }
        return $display;
    }, 10, 2 );

    The is will disable element ID 123 if the post has a featured image and if the disable featured image option is true.

    #1034618
    Steven

    Fantastic David – just what I needed! Appreciate the help.

    #1034960
    David
    Staff
    Customer Support

    Awesome – glad to be of help.

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