Site logo

Archived topic

Is it possible to show on element only on the first page or an archive?

7 replies · Started by Samuel on September 22, 2020

Viewing posts 1–8 of 8

The subject says it all--is there a way I can show an element on a blog page but only on the first page?

Unless I'm missing something this doesn't cover my use case. My use case is:

On the blog page insert a block element using the before content hook.

However I want to only show this element on the first page of the blog archive.

It should work just with a different filter:

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

    return $display;
} );

Let me know :)

Got it--what is available to the filter to target that one element? Is the id, etc passed to the filter?

Got it thanks

No problem :)

This archived topic is closed to new replies.