WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a custom-post-type for members of a firm. On the start-page I tried to call them via custom query but it shows an error. Heres my code: http://pastebin.com/rRzNcqPP and the error says: Call to a member function get_queried_object() on a non-object in /www/htdocs/w00e3b6a/hosting/basecamp/wp-includes/query.php on line 43

What did I wrong with the query?

share|improve this question
up vote 1 down vote accepted

just use


instead of

$wp_query = new WP_Query( array(
                    'post_type' => 'team-member',
                    'posts_per_page' => 2,
                    ) );

and then the while loop as

if(have_posts()) while(have_posts()) : the_post();

instead of

<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.