Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file

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.

Leave a Comment

tech