People are often confused about how to get data from global objects/variables
Question: In which ways can you inspect global variables?
This Q was written because it’s needed pretty often over here at WA. I just wanted to have it as a fav to link over here (people often don’t take a look at github gist links).
Feel free to modify the example if something is wrong or you think that the explanation is missing something. If you want to add other useful stuff, please add each as a single answer. Thank you.
Or, if you’re lazy, just install the Debug Bar plugin.
It adds a button to the admin bar that, when clicked, reveals a panel with all kinds of useful information, including deprecation notices, WP_Query variables and an SQL query log.
How to inspect the data:
Use this to get an insight view of what you can use from the current request/wp_query.
Btw:
How to actually get the data:
Examples
global $wp_registered_sidebars
Depending on where in process of loading the scripts and rendering the final output, some of the above mentioned variables may not be present. If you want a fairly inclusive view, perhaps a bit extreme, try:
var_dump is also nice in that tell you the type and formats the data a bit.