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)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0