- This topic has 6 replies, 3 voices, and was last updated 2 years, 3 months ago by
Josh.
-
AuthorPosts
-
October 11, 2022 at 10:16 pm #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”.
October 11, 2022 at 10:57 pm #2370623Fernando 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
October 11, 2022 at 11:45 pm #2370654Josh
I tried that loop. No love. Why doesn’t generate_before_loop show up in elements hooks?
October 11, 2022 at 11:50 pm #2370658Fernando 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?
October 12, 2022 at 7:38 am #2371050Josh
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 choosecustom hook
and then in the new text field I am typinggenerate_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?October 12, 2022 at 7:47 am #2371059David
StaffCustomer SupportHi 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.
October 12, 2022 at 7:49 am #2371125Josh
Thanks David AND Fernando!
-
AuthorPosts
- You must be logged in to reply to this topic.