Site logo

[Resolved] Display hook using Elements only on first page of Woocommerce archive

Home Forums Support [Resolved] Display hook using Elements only on first page of Woocommerce archive

Home Forums Support Display hook using Elements only on first page of Woocommerce archive

  • This topic has 10 replies, 2 voices, and was last updated 5 years ago by David.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1712629
    Thomas

    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 ?

    #1712702
    David
    Staff
    Customer Support

    Hi there,

    can you share a link to the site so i can see what the archive pagination is doing ?

    #1712763
    Thomas

    Answered in private mode

    #1713208
    David
    Staff
    Customer Support

    The ID has to be that of the Element – if you edit the element and take the ID in the URL.

    #1713850
    Thomas

    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 ?

    #1713855
    Thomas

    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 );

    #1713897
    David
    Staff
    Customer Support

    Is it a Hook Element that are you using ? If so what is it displaying ?

    #1713929
    Thomas

    I’m displaying a “Block – Hook” Element with 5 paragraphs of Lorem Ipsum at the bottom of the page.

    #1713936
    David
    Staff
    Customer Support

    In your filter snippet change: generate_hook_element_display to generate_block_element_display

    #1715572
    Thomas

    Super, it’s working perfectly. Thanks a lot David !
    Using GP on more and more projects and still learning news things each time 😀

    #1716002
    David
    Staff
    Customer Support

    Glad to hear that!

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.