Want to inspect global variables in WordPress? Use following code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 6 7 8 9 | /** * Inspect global variables in WordPress. */ function inspect_wp_query() { echo '<pre>'; print_r($GLOBALS['wp_query']) echo ' |
’;
}
// Query on public facing pages
add_action( ‘shutdown’, ‘inspect_wp_query’, 999 );
// Query in admin UI
add_action( ‘admin_footer’, ‘inspect_wp_query’, 999 );
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.