Fetch all published posts with pagination.
(self)
| 90 | return None |
| 91 | |
| 92 | def get_all_posts(self) -> List[dict]: |
| 93 | """Fetch all published posts with pagination.""" |
| 94 | all_posts = [] |
| 95 | page = 1 |
| 96 | params: dict = { |
| 97 | "per_page": 100, |
| 98 | "status": "publish", |
| 99 | "_fields": "id,title,slug,link,content,excerpt,date,modified,categories,tags", |
| 100 | } |
| 101 | while True: |
| 102 | params["page"] = page |
| 103 | posts = self.api_get("posts", params) |
| 104 | if not posts or not isinstance(posts, list): |
| 105 | break |
| 106 | all_posts.extend(posts) |
| 107 | print(f" Fetched page {page}: {len(posts)} posts (total: {len(all_posts)})") |
| 108 | if len(posts) < 100: |
| 109 | break |
| 110 | page += 1 |
| 111 | time.sleep(self.delay) |
| 112 | return all_posts |
| 113 | |
| 114 | def get_category_slug(self, cat_id: int) -> str: |
| 115 | """Get category slug by ID (cached).""" |
no test coverage detected