[Resolved] Generate_before_loop not showing in elements hook section.

Home Forums Support [Resolved] Generate_before_loop not showing in elements hook section.

Home Forums Support Generate_before_loop not showing in elements hook section.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2370607
    Josh

    When I try to create a new elements/hook I want to place it at before the loop of my archive page.

    In the archive I see :do_action( 'generate_before_loop', 'archive' );

    however when I look in the hook location of elements, only generate_after_loop shows.

    How can I add content between the title of the archive page and the content loop? This is for archive-product, which is woocommerce. Right now if I keep do_action( 'generate_archive_title' ); in my template it shows “This is where you can browse products in this store.” I want to replace that content with my own.

    I chose “custom hook” and added generate_before_loop, which seemed to work but it seems “hackish”.

    #2370623
    Fernando
    Customer Support

    Hi Josh,

    To clarify, are you referring to the Shop/Product Archive pages?

    If so, here’s an article you may refer to for hooks you may use there: https://www.businessbloomer.com/woocommerce-visual-hook-guide-archiveshopcat-page/

    Based on your description, you can try: woocommerce_before_shop_loop

    #2370654
    Josh

    I tried that loop. No love. Why doesn’t generate_before_loop show up in elements hooks?

    #2370658
    Fernando
    Customer Support

    Are you referring to why the Hook isn’t appearing on the Shop page? That hook isn’t available there. The shop page uses archive-product template from WooCommerce. It’s not controlled by GeneratePress.

    For reference, can you provide the specific link to the page in question?

    #2371050
    Josh

    I created a page based off archive.php. It includes content-product.php (which is based off content.php) which includes content-product-archive.php (this is a wordpress file). In content-product.php There is a line do_action( 'generate_before_loop', 'archive' );

    I’m trying to use that hook to add my paragraph.

    When I go into elements and create a hook-type element, one of the drop downs is “hook”. In that select list there is no generate_before_loop. To use this element I need to choose custom hook and then in the new text field I am typing generate_before_loop. I’m just curious why a hook that is part of generate press isn’t listed there. Is that hook not designed for this usage?

    #2371059
    David
    Staff
    Customer Support

    Hi there,

    we don’t list all the hooks in the Elements module, sometimes this is because the Hook as a very specific purpose and we don’t want it exposed, other times we have just not updated GP Premium to include it. In this case its probably a little of the former but mainly the latter.

    So using the Custom Hook type in this case is the way to go for now.

    #2371125
    Josh

    Thanks David AND Fernando!

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