Yoast: Building Page.ly Part4: Scalable and Fast Managed WordPress Hosting | Page.ly Blog http://t.co/ba32Hemn
![]()
Quick WP Tip: Simple WordPress debugging
After reading this post about the "WordPress white screen of death" I wanted to quickly share with you a quick hack I do in almost all WordPress installs I manage, that allows me to quickly switch on debug mode when needed.
In the file wp-config.php, usually found in your WordPress root, do the following:
if ( isset($_GET['debug']) && $_GET['debug'] == 'debug')
define('WP_DEBUG', true);Now I can open any page, and if something goes wrong there, like a white screen of death, I add ?debug=debug to its URL and see what's causing the trouble. Pretty easy huh? :)
Now it might be wise to change that second 'debug' to a key of your own choosing, so not everyone out there can open debug mode on your blog.






by digip on 17 August, 2010 at 23:05
Could you add that to functions.php?
by Steve on 17 August, 2010 at 23:07
Brilliant! Sure could have used this before. Thanks Yoast!
by Ozh on 17 August, 2010 at 23:08
Wow, http://yoast.com/wordpress-debug/?debug=true is ugly ;)
by Leon on 17 August, 2010 at 23:17
Thanks. And just in case anyone doesn't realise how to change that second 'debug' to a key of your own choosing, it's the third debug in the line of code above - "== 'debug')"
by nexik on 17 August, 2010 at 23:45
It's more secure to check if you are logged and have admin role. This way even if someone get your super secret key they won't see anything until they are admins on the blog.
by Theo on 17 August, 2010 at 23:53
Great, useful as always, thanks ! @nexik - neat idea.
Pingback: WordPress: Oh Those Actions and Filters!
by Ozh on 18 August, 2010 at 09:55
@nexik: when WP loads wp-config.php, functions such as the one getting info for the current user are not loaded.
The proper way to implement what you suggest is with a simple plugin:
add_action( 'init', 'my_debug'); function my_debug() { if( current_user_can('update_plugins') && isset( $_GET['debug'] ) && $_GET['debug'] == 'secret' && !defined( 'WP_DEBUG' ) ) { define( 'WP_DEBUG', true ); } }(hope the comment formatting won't crap out this)
by Joost de Valk on 18 August, 2010 at 09:56
The comment formatting actually makes it look great ;)
by Cristian O. Balan on 25 August, 2010 at 15:12
The Yoast suggestion on the wp-config file work fine but this code like a plugin don't work. Some idea?
by Andrew Nacin on 28 August, 2010 at 04:11
Unfortunately it's too late here to define WP_DEBUG. Really, the only way to do this is to have a 'secret' as said.
As long as you are logging WP_DEBUG instead of displaying it, you're in better shape. Just don't show them to the user.
by Pär Thernström on 18 August, 2010 at 10:37
That's so simple that it makes me angry that I did not think of it myself! :)
Great tip, thanks.
Pingback: links for 2010-08-18 | Links | WereWP
by Tom Hermans on 18 August, 2010 at 21:59
Yeah, this is pretty neat. Why didn't I know about this when I was puzzled by al that WP code, functions etcetera.. giving me more whitescreens than my frustration could handle.. ;)
by Chris on 19 August, 2010 at 11:46
Unfortunately I have the WSOD on the Dashboard and it doesn't work there ... I disabled the
Dashboard:
to avoid the WSOD, any ideas?
by Chris on 19 August, 2010 at 11:47
ups ... I meant
>?php //wp_dashboard(); ?<by Chris on 19 August, 2010 at 11:48
haha, stilt not quite ... :-D
by Ron on 19 August, 2010 at 14:43
Hi guys, im really a freaking noob here...hehe
just one question though, can i just add the code directly to wp-config.php
i was actually trying to have my blog on debug mode to check on something.,
peace out
by Joost de Valk on 19 August, 2010 at 14:44
Yes. :)
by Ron on 19 August, 2010 at 14:47
wow, thanks for the quick reply..:)
peace out
by Tailleur d'Images on 20 August, 2010 at 15:44
hi !
I've got a bug, but it doesn't cause a white page, it create a big mess when I write a new post (i.e. it erases lines of text when i add a new line between 2 paragraphs, it put a whole paragraph in H2, asl...)
so can i use this tip in order to fix it ? how ? i've been trying several things since now but it failed...
thx for help !
Pingback: August 20, 2010 | Throwing a Brick
Pingback: links for 2010-08-25 « Stevens Media
by mike on 27 August, 2010 at 15:45
I copied/pasted both Yoost original code and nexik admin code in the wp-config.php file -
and changed the third debug to my own secret word.
(and tried with the original ?debug=debug too)
but the only thing that happened was that the code-snippet was shown in the admin-page
and in the pages on the blog. (on top of the page)
and when pasting in the execution-snippet - nothing happens...
is there something I am missing here...?
regards
mike
Pingback: Configuring XAMPP as a Wordpress development server - memeLab: Web Publishing
by Larry Swanson on 31 August, 2010 at 01:15
I'm having the same problem as Mike, and I notice that the link to the debug=true for this page is no longer working (I saw it a week or so ago). Perhaps something changed in a WP release?
by Joost de Valk on 31 August, 2010 at 10:53
Yeah I disabled that on purpose :) has nothing to do with an upgrade :)
Pingback: Yoast: Quick Tip: Simple WordPress debugging | SEOBlog