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?

1 Answer 1


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(); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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