Site logo

Archived topic

How to Disable Hero in Page2, Page 3

2 replies · Started by Chaitanya on August 13, 2021

Viewing posts 1–3 of 3

Hi

I am using GeneratePress Premium, GenerateBlocks, and WP Show Posts.

To Display Front Page Hero Section (Featured Posts), I am using "Block - Page Hero"

This is the site: https://vsbytes.com/

Solved the problem of Pagination using this code:
https://generatepress.com/forums/topic/magazine-grid-2/#post-1277319 using the code

I don't want to show Page Hero on Page 2,3,4... And I don't want to use a separate page as the front page as the look cannot be achived.

https://vsbytes.com/page/2/

How to disable it on those pages. I want to show it only on the front page.

or

it will also be Good if the 2nd page displays the post 13, 14 in Hero followed by 15 to 25 in Archive.

Since the First Page has 1,2 Post in Hero and 3 to 12 in the Archive section.

After doing hours of research, I added the below code

add_filter( 'generate_block_element_display', function( $display, $element_id ) {
if ( 58 === $element_id && is_paged() ) {
$display = false;
}

return $display;
}, 10, 2 );

And the Problem is solved.

Glad to hear you found the solution.
As a note, we added a Global filter for All Elements display conditions.
See here:

https://docs.generatepress.com/?s=_element_display

The generate_element_display can be used in place of any of the legacy element specific filters

This archived topic is closed to new replies.