I would like to know how to hook a function in the footer area right before the </body> tag. The function would produce html.

function html_footer(){
    does stuff

I've done some research on the subject but it seems like there are a lot of different methods but all of them are deprecated. So I'm not sure what the right method would be.

For example in wordpress it would be:

function your_function() {
    echo '<p>This is inserted at the bottom</p>';
add_action( 'wp_footer', 'your_function' );

1 Answer 1


You can create one block and add the html content and place this block in the footer region. This content will place inside the tag and after the main content. Thats mean you will get your content before the closing tag.

  • I have a function generating the HTML so its not static. i need some way of hooking the function to the footer.
    – bakingsoda
    Jun 29, 2015 at 13:57
  • If you generating the html from from a function, why can't you make this function as block and place the block in the footer region. You will get option to disable and enable the block, also you will get more options to control the block. If you don't want to use block, then you can make use of hook_page_build like this - function hook_page_build(&$page) { $page['page_bottom'] = array( '#markup' => your_html_content(), ); } Jun 30, 2015 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.