habulaj commited on
Commit
f911c2c
·
verified ·
1 Parent(s): 420606c

Update routers/wordpress.py

Browse files
Files changed (1) hide show
  1. routers/wordpress.py +12 -1
routers/wordpress.py CHANGED
@@ -69,4 +69,15 @@ async def create_wordpress_post(post: WPPost):
69
  if response.status_code not in [200, 201]:
70
  raise HTTPException(status_code=response.status_code, detail=response.text)
71
 
72
- return response.json()
 
 
 
 
 
 
 
 
 
 
 
 
69
  if response.status_code not in [200, 201]:
70
  raise HTTPException(status_code=response.status_code, detail=response.text)
71
 
72
+ result = response.json()
73
+
74
+ # 🔄 Fallback: Se ACF não foi salvo, tentar novamente
75
+ if post.subhead and not result.get("acf", {}).get("subtitulo"):
76
+ post_id = result.get("id")
77
+ if post_id:
78
+ acf_data = {"acf": {"subtitulo": post.subhead}}
79
+ update_resp = await client.post(f"{WP_URL}/posts/{post_id}", auth=AUTH, json=acf_data)
80
+ if update_resp.status_code in [200, 201]:
81
+ result = update_resp.json()
82
+
83
+ return result