• 0

When I add code using the same hook via Hook Editor or functions.php, they end up in different places


Question

Posted · Report post

When I use the wp_footer -hook to add some code to my page, the code ends up in different place if I use the child-themes functions.php than if I use the Hooks Editor in the WordPress-admin.

When I use the Hooks Editor to add code to wp_footer, it goes to the footer. Nice!

When I use functions.php and write: 


function testfunction1() {
    echo '<!-- the same (?) test used in child-themes functions.php-->';
}
add_action('wp_footer', 'testfunction1', 10);

It doesn't go to the footer. Instead when I look at my source code it's about 1/4 from the top.

Am I using hooks wrong? Shouldn't this have the same result and the code in the wp_footer (before closing </body>  tag)

Thanks!

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

Posted · Report post

Hi,

 

I have no issue using a hook with wp_footer

 

function testfunction1() {
    echo '<!--Hello World-->';
}
add_action('wp_footer', 'testfunction1', 20);
 

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hmm. I have no idea why it now works when I copy-pasted your code. I disabled/enabled plugins, removed all custom stuff in Hooks Editor etc so maybe something just messed something up
Thanks anyway!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

No problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now