Return subpages of an author if the parent page was published by an other author

Solved


I’ve solved the problem and I’m going to share the code I used, so other developers that have this issue too can cope with it.

The get_pages()-function accepts the “hierarchical” argument. By default it’s set to 1 (true), which means, that WordPress searches the pages in hierarchical order to find the other parameters. If – as in my case – you search for pages of an author that are children of pages posted by a different author, WordPress will not find them!
To avoid this undesired behavior, you have to set the “hierarchical” argument to false (= 0).

This tells WordPress to search the pages for the given arguments without adhering to the hierarchy.

So to return all the pages of a given author, you have to use the following code:

$pages_args = array(
  'sort_order' => 'asc',
  'sort_column' => 'post_title',
  'authors' => $author_id, // has to be a string!!!
  'post_type' => 'page',
  'post_status' => 'publish',
  'hierarchical' => 0
);