0

Situation

I am using the Advanced Custom Fields plugin to give Custom Post Types a checkbox. If this box is checked, it should be returned by this Query. The Query works this far.

The issue

The pages I want it to display are all childs of a page. And this Query returns all pages with the checkbox, instead of just the childs of the current page with the checkbox.

My code

top of page

<?php $tid = get_the_ID(); ?>

Further along the page

<?php
  $i == 0;
  global $post;
  $myposts = new WP_Query(array(
     'post_type' => 'keuringen',
     'child_of' => $tid,
     'meta_query' => array(
         array(
         'key' => 'first_to_load',
         'value' => '1',
         'compare' => '=='
         )
     )
  ));
?>

The question What can I do to make it return only the children? Or should this already return only the children and is this a bug in one of the plugins?

0

WP_Query doesn't have child_of argument.

All you can do is to add post_parent argument, but it will work a little bit different - it selects only posts with parent set to given page. (It will return only direct children, and not grandchildren of given page/post).

| improve this answer | |
  • I think this might be it. The wordpress documentation isn't as clear as it could be on this subject. If this works, I'll resolve it in 9 minutes. – SMillerNL Jul 4 '13 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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