0

I noticed HTML comment tag <!-- --> will cause issue on themes functions.php script if it is in the root of script(not inside a function).
I was working on my themes functions.php to add some Easy Digital Downloads action/filter, which i realized purchase button will continue to loading and doesnt add product to basket.
after clearing an html comment that was in the root of script,issue solved. i need to know whats wrong with having HTML comment in functions.php root ?

(BTW my wp site is hosted on a cpanel shared host)

1
  • Please include some code snippets.
    – Den Isahac
    Dec 1, 2020 at 13:55

1 Answer 1

0

The functions.php is loaded before WordPress has sent the HTTP response headers. If you have raw HTML content in that file, even a HTML comment, then that will be sent immediately, triggering PHP's built-in HTTP headers.

Now, WordPress doesn't know about this and tries to send the headers as usual. And that will cause an error message like "Headers already sent …". This message comes with information about the file and line that created the first output, so it's rather easy to debug.

Long story short: Don't create raw output in the functions.php, use template files for that.

2
  • as edd add button is ajax ,how can i see output error in chrone developer tools?should i enable an option in config.php or something else?
    – alex
    Dec 1, 2020 at 14:51
  • @amin That's a completely different question. :) Please use a new, separate question for that.
    – fuxia
    Dec 1, 2020 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.