Use this to get an insight view of what you can use from the current request/wp_query
.
1 2 3 4 5 | function inspect_wp_query() { echo '<pre>'; print_r($GLOBALS['wp_query']) echo ' |
’;
}
// If you’re looking at other variables you might need to use different hooks
// this can sometimes be a little tricky.
// Take a look at the Action Reference: http://codex.wordpress.org/Plugin_API/Action_Reference
add_action( ‘shutdown’, ‘inspect_wp_query’, 999 ); // Query on public facing pages
add_action( ‘admin_footer’, ‘inspect_wp_query’, 999 ); // Query in admin UI
How to actually get the data:
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Example (not the best one) (Object) WP_Query -> post (stdClass) -> postdata (Array) // How to get the data: // Save object into var $my_data = new WP_Query; // on a new object // or on the global available object from the current request $my_data = $GLOBALS['wp_query']; // get object/stdClass "post" $my_post_data = $my_data->post; // get Array $my_post_data = $my_data['post']; |
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.