MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / get_all_posts

Method get_all_posts

scripts/migrate_posts.py:92–112  ·  view source on GitHub ↗

Fetch all published posts with pagination.

(self)

Source from the content-addressed store, hash-verified

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)."""

Callers 2

list_postsMethod · 0.95
migrateMethod · 0.95

Calls 1

api_getMethod · 0.95

Tested by

no test coverage detected