WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So you know how Drupal has functions in modules like Devel that allow you to output arrays in a nice format like dsm($array) or krumo($array)... Does WordPress have an equivalent or a nice way of displaying print_r($array)?

share|improve this question
what is wwrong with var_dump() or print_r() ? what exactly are you aiming for ? (i am sorry, I do not know druppal so well .. – krembo99 Feb 2 '12 at 2:27
krumo allows users to print arrays into a formatted list that expands on click. So instead of having <pre>-wrapped print_r output everywhere, you end up with some very nice dropdown lists instead. Much nicer to display! – emc Feb 2 '12 at 2:36
up vote 12 down vote accepted

I created a Kint plugin that works really well. I also integrates with the Debug Bar plugin. You can download it at: http://wordpress.org/extend/plugins/kint-debugger/

There are a few functions to help you out with WordPress specific globals:

  • dump_wp_query()
  • dump_wp()
  • dump_post()

For printing arrays in a styled, collapsible format you would do the following.

$foo_bar = array(
    'foo' => 'bar',
    'bar' => 'oof',
    'rab' => 'foo'
d($foo_bar); //Styled
s($foo_bar); //Un-styled
share|improve this answer
What a great idea, cheers. – Wyck Feb 15 '12 at 22:18

You can install and use Krumo with WordPress (or any php app really). there's the Hikari Krumo plugin that simplifies use, though check the comments there, there's an error that you'll need to manually fix to get it working with latest WP. There's also the WordPress Debug Bar plugin which you might find useful.

EDIT- Another option I've recently discovered, Kint; screenshot:

Kint screenshot

share|improve this answer

For this kind of stuff, I wrote REF (requires PHP 5.3). Among many other features, it displays contents of DocBlock comments and linkifies PHP-internal classes, methods and functions (links point to the PHP manual). It also handles WordPress functions (links point to queryposts.com).

Here's the output of $GLOBALS at the setup stage of WordPress in HTML mode (r($GLOBALS); in functions.php):

enter image description here

share|improve this answer
+1 for DB user root and an empty password. – toscho Jan 4 '13 at 11:52
lol never thought WP would actually store that too :) – onetrickpony Jan 4 '13 at 12:01
One Trick, the image went missing. – brasofilo Apr 2 '13 at 15:06
Seems to show up for me. I added a new one to reflect the last updates to this script – onetrickpony Apr 2 '13 at 16:25
This is incredible!! SO needed. – emc May 17 '13 at 16:02

Also you can use the plugin Debug Objects; list also scripts and styles. The Plugin has many more options for dev and debugging, but also this feature.

Alternative is this source, you find informations and the post about this topic here:

add_action('wp_footer', 'fb_urls_of_enqueued_stuff');
add_action('admin_footer', 'fb_urls_of_enqueued_stuff');
function fb_urls_of_enqueued_stuff( $handles = array() ) {
    global $wp_scripts, $wp_styles;
    // scripts
    foreach ( $wp_scripts -> registered as $registered )
        $script_urls[ $registered -> handle ] = $registered -> src;
    // styles
    foreach ( $wp_styles -> registered as $registered )
        $style_urls[ $registered -> handle ] = $registered -> src;
    // if empty
    if ( empty( $handles ) ) {
        $handles = array_merge( $wp_scripts -> queue, $wp_styles -> queue );
        array_values( $handles );
    // output of values
    $output = '';
    foreach ( $handles as $handle ) {
        if ( ! empty( $script_urls[ $handle ] ) )
            $output .= $script_urls[ $handle ] . '<br />';
        if ( ! empty( $style_urls[ $handle ] ) )
            $output .= $style_urls[ $handle ] . '<br />';
    echo $output;
share|improve this answer

Why not just use xdebug?

Looks pretty neat to me, by default.

enter image description here

There is also Kint, http://code.google.com/p/kint/ but I found the dropdowns more confusing, then the full output of xdebug.

share|improve this answer
+1 And don't forget to configure it in your php.ini file to avoid those nasty ... for nested stuff. – kaiser Jan 4 '13 at 11:58

If you just wrap the print_r() in <pre> tags it will output beautifully. If you're looking for a bit better diagnostics than that, black box and the debug bar posted by @Milo are my gotos.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.