Home › Forums › Support › Display Rules for Element to Show Only on Home Page Not on Page 2, 3, 4, etc
- This topic has 10 replies, 4 voices, and was last updated 5 years, 4 months ago by
David.
-
AuthorPosts
-
January 24, 2019 at 5:35 pm #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.
January 24, 2019 at 5:45 pm #791528Tom
Lead DeveloperLead DeveloperHi 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 🙂
January 24, 2019 at 6:23 pm #791547Brandon
Where do I place the code?
January 24, 2019 at 6:35 pm #791555Leo
StaffCustomer SupportJanuary 24, 2019 at 7:13 pm #791570Brandon
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?
January 24, 2019 at 8:11 pm #791597Leo
StaffCustomer SupportGood question.
Can you open a new topic for it?
It might be useful for others as well.
Thanks!
July 16, 2020 at 11:41 pm #1366332Jason
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
July 17, 2020 at 2:28 am #1366477David
StaffCustomer SupportHi 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; } );July 17, 2020 at 3:26 am #1366532Jason
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.
July 17, 2020 at 8:15 am #1366901Leo
StaffCustomer SupportIs 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 🙂
November 18, 2020 at 4:20 pm #1536881David
…..
-
AuthorPosts
- You must be logged in to reply to this topic.