{"id":42738,"date":"2023-03-07T15:00:33","date_gmt":"2023-03-07T14:00:33","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=42738"},"modified":"2023-03-01T18:24:38","modified_gmt":"2023-03-01T17:24:38","slug":"wordpress-debug-mode","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/wordpress-debug-mode\/","title":{"rendered":"WordPress Debug Mode Explained"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]If only someone could guarantee that your WordPress website would run for its life without any issues and errors. Unfortunately, running a website means you\u2019ll have an occasional problem. It might be a <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-fix-issues-with-slow-wordpress-admin-dashboard\/\">slow admin dashboard<\/a>, <a href=\"https:\/\/qodeinteractive.com\/magazine\/fix-wordpress-publishing-failed-error\/\">failure to update or publish posts<\/a>, or a <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-fix-broken-image-in-wordpress\/\">broken image link or two<\/a> \u2013 sooner or later, something bad will happen, something will break, or stop working as intended. Enabling WordPress\u2019 debug mode can sometimes be a part of the process of fixing the issues.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this article, we\u2019ll be talking about debugging and WordPress. Usually the purview of developers, debugging is something regular WordPress users, with little to no experience with coding, typically don\u2019t come across. And it\u2019s a shame because it\u2019s a handy tool.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]So, sit back and get ready to learn:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#what-is-debugging\">What Is Debugging?<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#how-to-enable-wordpress-debug-mode-manually\">How to Enable WordPress Debug Mode Manually<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#how-to-enable-wordpress-debug-mode-using-plugin\">How to Enable WordPress Debug Mode Using a Plugin<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#whats-next\">What\u2019s Next?<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;80px&#8221;][vc_widget_sidebar sidebar_id=&#8221;new-top-picks-banner&#8221;][vc_empty_space height=&#8221;80px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"what-is-debugging\"><\/a>What Is Debugging?<\/h2>\n<p>[\/vc_column_text][vc_column_text]<strong>Debugging, as its name suggests, is finding and removing bugs from software.<\/strong> Typically, it\u2019s something people who create or are familiar with the software\u2019s code perform. It\u2019s a standard part of software development and use \u2013 <strong>no code is perfect and debugging helps find errors and fix them.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>WordPress, a CMS written in PHP, is software with handy debugging tools.<\/strong> These tools won\u2019t solve your website\u2019s problems, which will likely require human intervention, but they will alert you to specific errors and warnings.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"how-to-enable-wordpress-debug-mode-manually\"><\/a>How to Enable WordPress Debug Mode Manually<\/h2>\n<p>[\/vc_column_text][vc_column_text]While WordPress has built-in debugging tools, they\u2019re not turned on by default \u2013 you have to do it on your own. <strong>You can do it manually, with the help of a plugin, or through your web hosting dashboard if that\u2019s an option your host offers.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To do it manually, you need access to the wp-config.php file. We have a thorough guide on <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-edit-wp-config-file\/\">editing the wp-config.php<\/a>, so please give it a look to find out the ins and outs of accessing and editing the file using FTP.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you locate and open the file, locate the following line of code:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/* That\u2019s all, stop editing! Happy publishing. *\/<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Any changes you make to the file <strong>should go above that line<\/strong>. The code you could add might look something like this:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_DEBUG', true );\r\ndefine( 'WP_DEBUG_LOG', true );\r\ndefine( 'WP_DEBUG_DISPLAY', false );\r\n@ini_set( 'display_errors', 0 );\r\ndefine( 'SCRIPT_DEBUG', true );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You enable the debug mode in the first line by setting WP_DEBUG to \u2018true.\u2019 <strong>This means WordPress will start showing you debug messages.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In the second line, by setting WP_DEBUG_LOG to \u2018true,\u2019 <strong>you\u2019re making sure those messages are stored in a debug log<\/strong>. You must enable the log if you want permanent debug message storage.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In the third and fourth lines, you\u2019re disabling the display of messages by setting WP_DEBUG_DISPLAY to \u2018false.\u2019 <strong>If you skip this step, the messages will show on your website, presenting a security risk and potentially preventing the pages from loading correctly.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Setting SCRIPT_DEBUG to \u2018true\u2019 will ensure WordPress uses the full, non-minified versions of core CSS and PHP.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"how-to-enable-wordpress-debug-mode-using-plugin\"><\/a>How to Enable WordPress Debug Mode Using a Plugin<\/h2>\n<p>[\/vc_column_text][vc_column_text]If you\u2019re uncomfortable editing the wp-config.php file manually, or if you don\u2019t have FTP access to the website, you can always turn to plugins for help. There are a couple of plugins you could use for debugging.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>We\u2019ll start with the one that lets you directly enable debug mode.<\/strong> Called <a href=\"https:\/\/wordpress.org\/plugins\/wp-debugging\/\" target=\"_blank\" rel=\"noopener\">WP Debugging<\/a>, the plugin allows you to enable debug mode and enable many of the tools you can also enable manually.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/WP-Debugging.jpg\" class=\"attachment-full size-full\" alt=\"WP Debugging\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/WP-Debugging.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/WP-Debugging-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/WP-Debugging-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/WP-Debugging-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]To get started, navigate to <em>Plugins &gt; Add New<\/em>, search for the plugin, and install and activate it. From there, move to <em>Tools &gt; WP Debugging<\/em>, <strong>where you\u2019ll see all the constants the plugin is enabling\/disabling.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"570\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/Debugging-Constants.jpg\" class=\"attachment-full size-full\" alt=\"Debugging Constants\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/Debugging-Constants.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/Debugging-Constants-300x176.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/Debugging-Constants-768x452.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2023\/03\/Debugging-Constants-620x365.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Installing the plugin enables debug mode, message logging, full CSS and PHP file usage, and saving database queries to an array for later display using SAVEQUERIES.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Optionally, the plugin lets you disable the display of debug messages, which might be recommended, and it also enables you to disable the fatal error handler introduced with WordPress 5.2.<strong> When you uninstall the plugin, it will try to revert all the settings to default.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"whats-next\"><\/a>What\u2019s Next?<\/h2>\n<p>[\/vc_column_text][vc_column_text]After you\u2019ve set up the debug mode and enabled the log, the troubleshooting can begin. After replicating the condition that led to the error, you can access the log and see what notifications and warnings the debug mode issued. Armed with that knowledge, you \u2013 or any other person skilled with debugging \u2013 can proceed with any necessary steps. <strong>These steps could involve fixing your website\u2019s code and letting theme or plugin developers know of the issues their products have caused you.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You can also use additional plugins when debugging your website to make the process easier or to expand its scope. <a href=\"https:\/\/wordpress.org\/plugins\/query-monitor\/\" target=\"_blank\" rel=\"noopener\">Query Monitor<\/a> is a plugin we\u2019ve covered <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-query-monitor\/\">in an article<\/a>.<strong> It\u2019s a tremendously helpful plugin that lets you see database queries, PHP errors, enqueued scripts and stylesheets, HTTP API requests, and a whole host of other information on every page load.<\/strong> It\u2019s a necessary plugin for troubleshooting WordPress.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<a href=\"https:\/\/wordpress.org\/plugins\/debug-bar\/\" target=\"_blank\" rel=\"noopener\">Debug Bar<\/a> is another commonly recommended plugin to help you out when debugging your website.<strong> The plugin gives you access to a debug menu right from the admin bar, where you can see queries and cache.<\/strong> It also lets you keep track of PHP warnings and notices if you have the debug mode on.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You should note that some other plugins might have features that could help you when debugging your website. <a href=\"https:\/\/wordpress.org\/plugins\/jetpack\/\" target=\"_blank\" rel=\"noopener\">Jetpack<\/a>, <strong>for example, has an activity log that keeps track of all the changes made to the website, complete with the data on the users who created them<\/strong>. This information can be invaluable when identifying the cause of some issues.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Let\u2019s Wrap It Up!<\/h2>\n<p>[\/vc_column_text][vc_column_text]Debugging is a normal part of ensuring that your website works well. It\u2019s a part of the process when building things like themes and plugins \u2013 or at least it should be \u2013 just like it\u2019s a part of ensuring that your website, as a whole, works well. Because when it doesn\u2019t, and that\u2019s bound to happen, it\u2019s the debug mode you\u2019ll turn to to find out what went wrong.<br \/>\n[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Ever wondered what the WordPress debug mode does and how to enable it? In this article, we&#8217;ll try to answer those questions. <\/p>\n","protected":false},"author":9295,"featured_media":42750,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[350,163,34,4],"class_list":["post-42738","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resources","tag-debug","tag-performance","tag-security","tag-tips"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/42738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/9295"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=42738"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/42738\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/42750"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=42738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=42738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=42738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}