How to add code to `head` with WordPress 5.9 FSE (Full Site Editing)

As far as I understand the wp_head and wp_footer actions should still work under FSE in WP 5.9+, through the template canvas PHP file that’s loaded through the locate_block_template(). That PHP file contains the basic HTML structure and there we find e.g. the familiar wp_head() and wp_footer() function calls that we usually had in the old footer.php and header.php theme files. The current block template HTML from get_the_block_template_html() is now displayed within the body tag from the template canvas.

So in FSE use e.g. the theme’s functions.php file or a custom plugin to add your wp_head and wp_footer actions in PHP.

Leave a Comment

tech