Skip to main content
1 of 2
Sam
  • 435
  • 6
  • 18

###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
);
Sam
  • 435
  • 6
  • 18