Archived topic
Display hook using Elements only on first page of Woocommerce archive
10 replies · Started by Thomas on March 28, 2021
Hi, trying to make this work since a few hours,
I found this snippet : https://generatepress.com/forums/topic/element-hook/#post-1012294
Which I added to my child theme function.php but it seem to be not working.
Any suggestion please ?
Hi there,
can you share a link to the site so i can see what the archive pagination is doing ?
Answered in private mode
The ID has to be that of the Element - if you edit the element and take the ID in the URL.
Ok, so I finally ended up by replacing the 10 value by 4625 that I found in Element URL as following : /post.php?post=4625&action=edit
But finally, still same. I have no cache plugin and clear my browser cache just in case.
Any idea please ?
Just in case, here is the code snippet in child theme function.php
add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
if ( 4625 === $element_id && is_paged() ) {
$display = false;
}
return $display;
}, 10, 2 );
Is it a Hook Element that are you using ? If so what is it displaying ?
I'm displaying a "Block - Hook" Element with 5 paragraphs of Lorem Ipsum at the bottom of the page.
In your filter snippet change: generate_hook_element_display to generate_block_element_display
Super, it's working perfectly. Thanks a lot David !
Using GP on more and more projects and still learning news things each time :D
Glad to hear that!