I am trying to use the loop_start hook to write an action for all pages on my site. It works on normal pages, but not on pages that use the Advanced Layout Builder.
This code works on regular pages, like this one: http://209.216.16.238/test/:
function add_page_test() {
echo 'Hello!';
}
add_action('loop_start', 'add_page_test');
However, it does not work on this page: http://209.216.16.238/gulf-coast/cape-san-blas/, which uses the ALB.
Is there a different hook I can use instead of “loop_start”, so that this works?
Thanks!
Hi blizzmarketing!
The template builder doesn’t use the regular page content so I doesn’t sound like the loop_start would be triggered. I’ve never actually seen the loop_start used so I had to look it up and even then not much documentation.
If you want something to run at the very top of the page you could hook it onto the header or look at the template-builder.php file and add your own action to a child theme which would then run where you want it.
Best regards,
Devin
Hi Devin,
I don’t want something to run at the very top of the page. I’d like to add something right before any of the content from the ALB starts. Do you know what hook I’d want to use? I looked at template-builder.php but it was not obvious to me.
Thanks!
Add the template-builder file to your child theme and then add a hook or function call wherever you’d like it.