Get only 1 Most Recently Modified Child Post from Parent

I think maybe you don’t need Wp_Query. I believe you can just do

$episodes_for_front_page = array();

//get the two dramas
$dramas = get_posts(array('post_type' => 'drama'));

foreach ($dramas as $drama){
  
  //get all the episodes belonging to that drama, sorted by most recent update
  $episodes = get_posts(
    array(
      'post_type' => 'episode',
      'post_parent' => $drama->ID,
      'orderby' => 'post_modified',
      'order' => 'DESC'
    )
  );

  //add the most recent episode to the list of posts to display
  $episodes_for_front_page[] = $episodes[0];
}

Leave a Comment