Como inspecionar os dados:
Use isso para obter uma visão detalhada do que você pode usar na solicitação atual / wp_query.
function inspect_wp_query()
{
echo '<pre>';
print_r($GLOBALS['wp_query'])
echo '</pre>';
}
// 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
Btw:
// this:
global $wp_query;
$wp_query;
// is the same as
$wp_query;
// and as this:
$GLOBALS['wp_query'];
// You can do this with each other global var too, like $post, etc.
Como realmente obter os dados:
// 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'];
Exemplos
Listar todos os nomes da barra lateral?
(Gere uma lista suspensa / selecione um objeto com todas as barras laterais dentro da
global $wp_registered_sidebars
)