immediately after the opening
<body>
tag
WordPress doesn’t provide a hook for that, i.e. for adding code exactly after the <body>
tag.
But WordPress does fire a hook named login_header
which we can use to add code after the body
tag is opened:
do_action( 'login_header' )
Fires in the login page header after
the body tag is opened.
So for example:
add_action( 'login_header', 'wpse_375598' );
function wpse_375598() {
?>
Add your HTML here.
<?php
}
And BTW, login_body_class
is a filter hook one can use to add custom CSS classes into the <body>
tag (i.e. <body class="here">
), so that hook should not be used to add the (Google Tag Manager’s) noscript
code.
Also in the edited question, the problem is that you used login_head
and not login_header
— login_head
is for adding code in the <head>
section of the document/page.
So your code should look more like:
add_action( 'login_head', 'wpse_375598_login_head' );
function wpse_375598_login_head() {
?>
Add your HTML here that goes in the <head>.
<?php
}
add_action( 'login_header', 'wpse_375598_login_header' );
function wpse_375598_login_header() {
?>
Add your HTML here that goes in the <body>.
<?php
}