Archived topic
I want this block/element only on first page/homepage
3 replies · Started by Chetan on December 5, 2022
The element which I added should only come on the first page/homepage. When I click on the second page there also it is showing. How can I show it only on the first page?
Hi Chetan,
You can use the generate_element_display hook. Reference:
Here's a code you may try:
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 100 === $element_id && is_paged() ) {
$display = false;
}
return $display;
}, 10, 2 );
Replace 100 with the ID of your Block Element.
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Getting the Element ID: https://share.getcloudapp.com/YEuDdrnQ
I am getting this error when i added this code
How are you adding the code?
Can you make sure it's using one of these methods?
Adding PHP: https://docs.generatepress.com/article/adding-php/