I'm new to Wordpress and I want to echo a script and a css file inside the footer.php . This is the code that I use.

echo "<script src='file.js'></script>";
echo '<link rel="stylesheet" type="text/css" href="file.css">';

The problem is that the codes are appearing at the top of the document, although I place them in the bottom of the footer.php file. Why is this happening? wordpress php outside the html

  • 3
    You cannot add styles in the footer. <link> tags outside the <head></head> tags is invalid HTML – Pieter Goosen Jan 29 '15 at 19:25
  • 4
    Make use of the system WordPress offers to enqueue scripts/styles, this answer gives you a good overview. – Nicolai Jan 29 '15 at 19:27
  • 3
    Also, use wp_enqueue_scripts to add styles and scripts – Pieter Goosen Jan 29 '15 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.