inspect the $wp_query global directly instead of relying on have_posts()

see #247