Jake Vanderwerf
2026-01-25 b38f03c0e7218762d90fa5092696b127f24f36db
inc/managers/queue/executors/UploadExecutor.php
@@ -385,6 +385,7 @@
      $defaultTitle = 'New '.$config['singular']. ' ';
      foreach($data['posts'] as $index => $post) {
         $progress->advance();
         $title = array_key_exists('post_title', $post['fields'])
            ? sanitize_text_field($post['fields']['post_title'])
            : $defaultTitle . ($index + 1);
@@ -405,6 +406,7 @@
         $parent = wp_insert_post($args);
         $progress->advance();
         if ($parent && !is_wp_error($parent)) {
            $childPosts = [];
            $featured = $post['fields']['featured']??null;
            $featuredID = null;
@@ -442,6 +444,8 @@
                  }
               }
            }
            $this->updateTimelineMetadata($parent);
         }
      }
      return new Result(
@@ -450,6 +454,30 @@
      );
   }
   /**
    * Update timeline parent post with count and latest date
    * @param int $parentId Parent timeline post ID
    */
   private function updateTimelineMetadata(int $parentId): void
   {
      // Get all child posts
      $children = get_children([
         'post_parent' => $parentId,
         'post_type' => get_post_type($parentId),
         'post_status' => ['publish', 'draft'],
         'orderby' => 'date',
         'order' => 'DESC',
         'fields' => 'ids'
      ]);
      // Count includes parent + children
      $number = count($children) + 1;
      // Update both meta fields
      update_post_meta($parentId, BASE . 'number', $number);
      update_post_meta($parentId, BASE . 'latest_date', time());
   }
   // ─────────────────────────────────────────────────────────────
   // Helper methods
   // ─────────────────────────────────────────────────────────────