Using WordPress ‘block_footer_area()’ PHP function

The block_footer_area() WordPress PHP function is utilized to print the footer block template part. However, it’s worth noting that if you’re using this function to create a hybrid theme, it won’t convert shortcodes that are inside the footer area when called in the footer.php of an old-style PHP template the way it does when it’s used inside a Full Site Editing (FSE) template or template part. Everything else works as expected.

Usage

Here’s a simple way to use the block_footer_area() function:

block_footer_area();

In this case, the function will output the footer block template part.

Parameters

  • This function does not take any parameters.

More information

See WordPress Developer Resources: block_footer_area

Examples

// In your theme's footer.php file, you can call the function like this:
block_footer_area();
// This will print the footer block template part.

Checking if function exists before using

// Always good to check if the function exists before using it
if (function_exists('block_footer_area')) {
    block_footer_area();
}
// This will check if the function is available before trying to print the footer block template part.

Combining with other functions

// You can combine it with other functions for more complex operations
if (function_exists('block_footer_area')) {
    block_footer_area();
    wp_footer(); // this function prints scripts or data before the body tag on the front end.
}
// This will print the footer block template part and then print any scripts or data placed before the body tag.

Using within a condition

// You can use it within a condition
if (is_page('contact')) {
    block_footer_area();
}
// This will print the footer block template part only on the 'contact' page.

Using within a function

// Use within your own function
function my_custom_footer() {
    block_footer_area();
}
// Now whenever you call my_custom_footer(), it will print the footer block template part.