• Hi guys,

    I just realized I can’t seem to use the wp_footer action hook anymore in any of the FSE themes (only tested with WordPress themes). I did a quick search in the code, and it’s nowhere to be found, in WordPress repo neither.

    Lot of scripts rely on this; why can’t I find any information about this at all? It’s super weird. And what’s the alternative?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    If you enqueue your scripts with the $in_footer arg set to true, their link reference will be output near the end despite the lack of wp_footer action. I’m not sure what now triggers the output, but it does happen. This is only for the editor. For front end output wp_footer action still works, at least with Twenty Twentythree theme that I tested it with. I’m still not sure where it gets done now, but it does happen.

    Thread Starter Jordy Meow

    (@tigroumeow)

    Are you 200% sure? ??

    I am trying this with Twenty Twenty-Three, in a fresh WordPress install, with no plugins installed:

    add_action('wp_footer', function () {
      die();
    });

    This code definitely doesn’t kill the website.

    Also, note that wp_footer() is called by the theme normally (and officially), an there is no mention to that function in the entire code of Twenty Twenty-Three.

    I didn’t find any mention that WordPress would call it magically in the case of FSE themes. I checked WordPress repo, and there are weird calls to wp_footer in legacy widgets are used, so on older installs, the function might be called.

    • This reply was modified 1 year, 9 months ago by Jordy Meow.
    Moderator bcworkz

    (@bcworkz)

    Works for me. Your reply did give me pause because at the time I last replied I did have a number of tabs open for various testing. It dawned on me that I may have been looking at the wrong tab. But no, it’s working for me.

    This displays the die message at the bottom of the page:
    add_action('wp_footer', function() {wp_die('wp_footer is working');});

    Dying alone isn’t that conclusive without closer examination since the action fires at the very end. The resulting HTML is unusual though. The page ends with </footer>, there’s no </body></html>, then for me the wp_die() page is output. Echoing a message instead of dying yields the message and proper closing tags.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Did the wp_footer disappeared in the FSE themes?’ is closed to new replies.