WordPress: Add code to the theme footer

Do you want to add any code or HTML to the footer of your WordPress website without editing the theme file? You can easily add Google Analytics or other code in the WordPress footer by editing the functions.php file of the theme.

Paste the code below in the functions.php file and add your HTML or code in the space provided. It will be added to the WordPress footer using the wp_footer function.

<?php
add_action('wp_footer', 'footer_code');
 
function footer_code() { ?>
    // Paste your Google Analytics or other code here
<?php } ?>