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
The subject says it all--is there a way I can show an element on a blog page but only on the first page?
Hi there,
See the second example here:
https://docs.generatepress.com/article/generate_header_element_display/#examples
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
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?
Yup - check out the first example here:
https://docs.generatepress.com/article/generate_header_element_display/#examples
Got it thanks
No problem :)