Working on updating an old WP site developed for WordPress 2.0 and have a post (page) query that does not return the "post_content" data.

Here is said query:

$the_query = query_posts('post_type=page&post_parent=50&post_status=publish&orderby=menu_order&order=ASC&posts_per_page=100');

And the returned object (one of them):

[0] => stdClass Object
        [ID] => 249
        [post_title] => John Doe
        [link_link] => 1
        [no_follow_link] => 0
        [redirect_url] => 
        [target_blank] => 0
        [post_status] => publish
        [post_name] => john-do
        [post_parent] => 50
        [guid] => http://beta.mysite.org/
        [post_type] => page
        [filter] => raw

Notably this is missing the post_content. Which is kind of a big deal. Any ideas? I don't think it's a memory limit issue. I've tried many different work-arounds. Suggestions are much appreciated.

  • See if this answer could help
    – Amit Kosti
    Commented Aug 10, 2012 at 16:13
  • disable all plugins, to see if any of them is messing up with the content filter.
    – pixeline
    Commented Aug 11, 2012 at 22:35

1 Answer 1


You shouldn't be using query_posts() here, but rather WP_Query(). (Search WPSE for query_posts if you want to know wy.)

$custom_query_args = array( 
    'post_type' => 'page',
    'post_parent' => '50',
    'post_status' => 'publish',
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'posts_per_page' => '100'
$custom_query = new WP_Query( $custom_query_args );

// To see the contents of the $custom_query object
var_dump( $custom_query );


No dice. Same result.

The query is returning exactly what it is intended to return. In order to access the $post data, you need to set up the Loop:

if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post() );

    // The $post variable is now available, 
    // so you can access the post content, either as
    // $post->post_content or as the_content()

endwhile; endif;

So, I'm guessing your problem is that you're not setting up the Loop.

  • No dice. Same result. Commented Aug 11, 2012 at 1:59
  • What, exactly, does the var_dump() return? Commented Aug 11, 2012 at 15:01

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.