admin管理员组文章数量:1287580
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.
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.
Share Improve this question asked Sep 18, 2021 at 14:14 Spencer HalsteadSpencer Halstead 156 bronze badges 1- 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
Reset to default 4As said on https://wordpress/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 thewp-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/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/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/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.
本文标签: phpWhere exactly do I write define( 39WPDEBUG39true ) in wpconfig file
版权声明:本文标题:php - Where exactly do I write define( 'WP_DEBUG', true ) in wp-config file 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741312482a2371725.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论