would anybody know where I would write WP_DEBUG in wp_config file. I don't see it there. I would like to check why my javascript is not working. I have enqueued everything with php in the functions.php file. My code is correct, so it must be something else.

  • 3
    "I would like to check why my javascript is not working" - WP_DEBUG might not show you anything useful here. Can I check you mean that your javascript isn't being enqueued on the page? I think that's all WP_DEBUG might help with, and even then I'm not optimistic. Or is it some other error? e.g. do you have errors in your browser debug console?
    – Rup
    Commented Sep 18, 2021 at 14:36

1 Answer 1


As said on https://wordpress.org/support/article/debugging-in-wordpress/#example-wp-config-php-for-debugging: (note though, the "blogging" below is now "publishing")

NOTE: You must insert this BEFORE /* That's all, stop editing! Happy blogging. */ in the wp-config.php file.

So just put it there, like this:

define( 'WP_DEBUG', true );

/* That's all, stop editing! Happy publishing. */

But actually, depending on the WordPress version that you're using (and your hosting setup or how you installed WordPress), the constant might already be in the wp-config.php file, which means you would just need to set the value to true, and for example in WordPress 5.8, the default config template has the following:

 * For developers: WordPress debugging mode.
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */

/* That's all, stop editing! Happy publishing. */

See https://wordpress.org/support/article/editing-wp-config-php/ for further information about editing the wp-config.php file.

However, I agree with @Rup, particularly if you've already tried to enable WP_DEBUG. So if you're specifically having a JavaScript-specific issue (e.g. you're trying to hide an element and yet it still shows up), then you should use the browser dev tools to debug the issue. You could also try inspecting the raw (or server-generated) HTML source on the page in question and confirm that your JS is indeed being loaded on the page (e.g. if your JS is in myscript.js in the theme folder, then check if the HTML contains a <script> tag with the src value looking something like https://example.com/wp-content/themes/your-theme/path/to/myscript.js).

And if it is, then the browser console would tell you if there's something wrong in your JS, e.g. you may have used $ (e.g. to access jQuery functions) and yet that variable never defined. Just like if WP_DEBUG/debugging is enabled and your PHP attempted to use a variable that was never defined, then the error log file would tell you about that issue.

  • I have an error in the console in dev tools that just says: Failed to load resource. the server responded with a status of 404. clock.png:1 Commented Sep 19, 2021 at 17:55
  • But, I think that error is because, I did not reference a clock image, but it should still tick, as it does in my text editor. Am I supposed to put a <script> tag with example.com/wp-content/themes/your-theme/path/to/myscript.js). on the page where I have put the html, is that what you mean. I have just put this html on the actual page : <div id="clockContainer"> <div id="hour"></div> <div id="minute"></div> <div id="second"></div> </div> Commented Sep 19, 2021 at 17:59
  • Basically, if you see myscript.js or whatever the actual name is, in the page's HTML source (or the "Sources" tab in Chrome dev tools), then your script is being enqueued correctly. And if your JS (i.e. the JS code in your script file) itself isn't working or causing an error in the browser console, then that's no longer a WordPress issue and instead it is a generic JS issue (which is not in scope or is off-topic on this stack).
    – Sally CJ
    Commented Sep 20, 2021 at 2:06
  • Thanks Sally. I cannot seem to see the check mark next to your answer. Could you please tell me if I am putting the html correctly on my actual page, as maybe I am supposed to reference the js in the js folder with wordpress, This is what I have done: <script src='artandleatherspencer.local/wp-content/themes/…) <div id="clockContainer"> <div id="hour"></div> <div id="minute"></div> <div id="second"></div> </div> Commented Sep 20, 2021 at 9:03
  • As for loading the script, see developer.wordpress.org/themes/basics/including-css-javascript for the proper way to do it in WordPress - try enqueuing the script in the footer, i.e. set the 5th parameter for wp_enqueue_script() to true. If you need further help in enqueuing the script, feel free to post a question on this stack and as always, be as detailed as possible.
    – Sally CJ
    Commented Sep 20, 2021 at 15:49

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.