[Support request] Display Rules for Element to Show Only on Home Page Not on Page 2, 3, 4, etc

Home Forums Support [Support request] Display Rules for Element to Show Only on Home Page Not on Page 2, 3, 4, etc

Home Forums Support Display Rules for Element to Show Only on Home Page Not on Page 2, 3, 4, etc

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #791519
    Brandon

    I added a hero header with the location rule of “Front Page.” My home page is my latest blog posts, and it has pagination links at the bottom for page 2, 3, 4, etc. I would like the hero header to only show on my home page and not at the top of everyone of my blog post archive pages that are linked off the home page, which is what is occurring right now.

    How do I accomplish this?

    Thanks for the help.

    GeneratePress 2.2.1
    GP Premium 1.7.7
    #791528
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This should likely happen by default. I wonder if there’s an argument for keeping the hero on paginated paged.

    For now, you can use this function:

    add_filter( 'generate_header_element_display', function( $display ) {
        if ( is_paged() ) {
           $display = false;
        }
    
        return $display;
    } );

    Let me know if that does the trick 🙂

    #791547
    Brandon

    Where do I place the code?

    #791555
    Leo
    Staff
    Customer Support
    #791570
    Brandon

    One more question…

    How can I get the Hero to show up at the bottom of the home page as opposed to the top of the home page. For example, below the posts and pagination but above the footer?

    #791597
    Leo
    Staff
    Customer Support

    Good question.

    Can you open a new topic for it?

    It might be useful for others as well.

    Thanks!

    #1366332
    Jason

    Is the filter as Tom suggested still the best way to achieve this outcome?

    edit: actually this doesn’t seem to work for me with metaslider

    #1366477
    David
    Staff
    Customer Support

    Hi there,

    yes, the method that Tom provided is to disable a Header Element when viewing a Paged page.
    How did you add the Meta Slider ? If its using a Hook Element then you would use this Filter:

    https://docs.generatepress.com/article/generate_hook_element_display/

    add_filter( 'generate_hook_element_display', function( $display ) {
        if ( is_paged() ) {
           $display = false;
        }
    
        return $display;
    } );
    #1366532
    Jason

    Yes, that works now David. Thank you.

    Is it better to use the Header Element or Hook Element? I can do either way, I’m just wondering which is better and more useful.

    #1366901
    Leo
    Staff
    Customer Support

    Is it better to use the Header Element or Hook Element? I can do either way, I’m just wondering which is better and more useful.

    Doesn’t really matter if you are adding a slider 🙂

    #1536881
    David

    …..

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