Bỏ qua để đến nội dung

Tags, categories, and media

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

Four tools cover the WP taxonomy + media surface:

  • list_taxonomies — list tags or categories on a site
  • create_taxonomy — create a new tag or category
  • upload_media — upload an image from a URL or base64 payload
  • The featured_media_id field on create_draft / update_draft

WordPress REST /wp/v2/posts expects tags and categories as arrays of integer IDs, not name strings. Two ways:

  1. Pass IDs directly if you already know them
  2. Pass name strings — the worker auto-resolves to existing terms or creates new ones (only deploy_md_to_site does this auto-create; for direct create_draft calls you do it yourself)
list_taxonomies site_id="<wp-site-id>" type="tags"

Returns [{ id: 12, name: "seo", slug: "seo" }, ...].

create_taxonomy site_id="<wp-site-id>" type="categories" name="Marketing"

Returns the new term { id: 47, name: "Marketing", slug: "marketing" }.

create_draft
site_id="<wp-site-id>"
title="Hello"
content_html="<p>Body</p>"
tags=[12]
categories=[47]
upload_media
site_id="<wp-site-id>"
source_url="https://example.com/hero.jpg"
filename="hero.jpg"
alt="Hero image — pricing page"

Returns { id: "1024", source_url: "https://yoursite.com/wp-content/uploads/.../hero.jpg" }.

Then:

update_draft
site_id="<wp-site-id>"
post_id="142"
featured_media_id=1024
  • upload_media is not available on Duda — Duda uses main_image: { url } directly in the post body via create_draft’s featured_image_url field.
  • No tool deletes media. To clean up uploaded files, do it in WordPress admin.