Skip to content

Editing content ​

With content write abilities exposed, an assistant can fill in and fix content: set field values on posts, terms and users, create and update posts and terms, publish or unpublish, and delete.

Values go through the same validation as the editor, and every change is recorded with a way to undo it.

Good practice for bulk changes ​

A change across many entries is where an assistant saves the most time, and where a mistake costs the most. A careful run:

  1. Counts first: "this touches 212 Books".
  2. Tries one entry as a dry run, and shows you the result.
  3. Works in batches under one task name, so the whole run can be reviewed and reversed together.

The vx-migrate-values prompt walks the assistant through exactly this.

What to know before exposing content writes ​

  • An empty value clears a field. Only the fields the assistant sends change, but sending an empty value deletes what was there. Expose the matching read abilities too, so the assistant sees current values before writing.
  • Some deletes can't be undone. Deleting a post moves it to the trash, which can be reversed. Deleting a post permanently, or deleting a term (WordPress has no trash for terms), can't be undone.
  • Assistants don't check post locks. If someone has a post open in the editor while an assistant changes it, the editor doesn't warn either of them, and whoever saves last wins. Assistants can guard against changes they didn't see, but a person with the post open won't see the assistant's change until they reload.
  • Assistants act with administrator rights. Content changes by an assistant aren't limited by the per-post permissions WordPress applies to other roles, because the connected account is an administrator.
  • User accounts are out of scope. An assistant can set users' field values, but can't create or delete accounts, or change roles, passwords or email addresses.

Posts and their fields are separate changes ​

A post's own properties (title, content, excerpt, slug, status, author, date, parent, menu order, featured image, terms, and whether it takes comments) are changed separately from its VX field values. A task that needs both is two steps of one task.

Putting posts in categories ​

An assistant assigns a post's categories, tags and other terms when it creates or updates the post, so a post can go live already in its categories, and many posts can be filed at once. You don't need a Taxonomy field for this, and WordPress's own category box stays as it is. The terms must already exist, so an assistant creates a missing one first.

Opening comments on existing posts ​

WordPress decides whether a post takes comments when the post is created. Turning on comments for a post type later leaves its existing posts closed, so an assistant opens them afterwards, many at a time. If the site closes comments on posts older than a set number of days (Settings → Discussion), those posts stay closed whatever the post says, and the assistant is told so.

Images and other files are added to the media library first, then used by their id: as the featured image, or in an Image, Gallery, Files, Video or Audio field. See Images and files.

Option pages ​

An assistant reads and writes an option page's settings by the page's key. A key the page has no field for is refused, and so is a value that fails a field's checks: in either case nothing is written, even when the settings span several fieldsets.

Comments ​

An assistant creates comments, changes their text, author, date, status and type, moves them to the trash or deletes them for good, and writes their field values, such as the rating of a review. A comment it creates is held for moderation unless it's asked to approve it, and it's written the way wp-admin writes one, without the flood and duplicate checks a visitor's comment gets.

Technical details for LLMs
  • Writes: vx-framework/set-post-values (patch; id or ids), vx-framework/create-post (draft by default; core props + initial values; template assigns a page template the active theme offers for the post type, default for none), vx-framework/update-post (core props only; ids allowed only for status, author, date, parent, menu_order, featured_image, template, comment_status, terms), vx-framework/set-post-status (id / ids), vx-framework/delete-post (trash; force: true permanent; id / ids); vx-framework/set-term-values, vx-framework/create-term, vx-framework/update-term (name, slug, description, parent; no ids), vx-framework/delete-term (permanent); vx-framework/set-user-values (values only).
  • Option page writes: vx-framework/set-option-page-values (patch; unknown keys refused; every fieldset is checked before any is saved, so a refused value, or with strict a warning, writes nothing and returns validation_error; a storage failure after the first fieldset can still return partial: true + written_keys).
  • Comment writes: vx-framework/set-comment-values (patch; id or ids; if_match from vx-framework/get-comment-values; needs edit_comment, and a Comment Type location with no viewer condition also needs moderate_comments). vx-framework/create-comment (post required; content, type, parent, author_name / author_email / author_url, user, date, status default hold, initial values; undo trashes it), vx-framework/update-comment (patch over the same properties; status is approve | hold | spam, and also takes a trashed comment out of the trash; ids only for status and type), vx-framework/delete-comment (trash; force: true permanent; id / ids; replies move up to the parent).
  • Comments on a post: comment_status (open | closed) on create-post / update-post; refused with comments_not_supported on a post type without comments support (post_comments in the post type config). Create defaults to WordPress's default for the type. Opening one that comments_open() still reports closed returns a warning: comments_closed_by_age (Discussion's close-after-N-days setting, for the post types close_comments_for_post_types names, post by default) or comments_closed_by_site (another comments_open filter). vx-framework/get-post-values reports comment_status on post types that support comments.
  • Terms: terms: { <taxonomy>: [term ids] } on create-post / update-post. Each named taxonomy's terms are replaced (wp_set_object_terms, not appended) in the order given; [] clears one; unnamed taxonomies are untouched. Errors: invalid_terms (not keyed by taxonomy, or not a list of positive ids), unknown_taxonomy (not registered for the post type), unknown_term (an id that isn't a term of that taxonomy), cannot_assign_terms (no assign_terms), and on create-post terms_conflict when values also sets the taxonomy through a Taxonomy field. Terms are applied after the values and before the status; a failure leaves a create a draft with terms_failed. On create, WordPress's default category still applies to a post when category isn't named. vx-framework/get-post-values returns terms for every taxonomy of the post type ([] for none, {} for a type with no taxonomies); the undo restores the previous terms of the named taxonomies only.
  • Conditional logic on patches: conditions are read over the stored values with the sent ones on top; a sent field its conditions hide isn't written, and returns a hidden_by_conditions warning when its value differs from the stored one.
  • Errors and warnings are { path, code, message }: message is translated, code is fixed. Value codes: required, hidden_by_conditions, minlength, maxlength, min, max, min_items, max_items, min_rows, max_rows, layout_min_rows, layout_max_rows, min_files, max_files, min_count, max_count, unknown_term, invalid_email, invalid_phone, invalid_url, invalid_color, invalid_date, invalid_time, invalid_date_range, end_before_start, invalid_file, attachment_not_found, file_type_not_allowed, file_extension_blocked, file_too_large, files_too_large, invalid_row, missing_layout, unknown_layout, unknown_field, not_writable, write_failed, delete_failed; a rule added with vxframework/fieldsets/validation_rules reports its type; anything else invalid_value. Only the file codes (invalid_file, attachment_not_found, file_type_not_allowed, file_extension_blocked) block a non-strict write. Post and term property errors carry codes too (invalid_status, unknown_author, not_an_attachment, unknown_template, invalid_date, needs_future_date, unknown_parent, own_parent, parent_loop, duplicate_name, empty_name, invalid_comment_status, comments_not_supported, invalid_terms, unknown_taxonomy, unknown_term, cannot_assign_terms, terms_conflict).
  • Codes from Pro field types: max_entries, missing_start, min_date, max_date, invalid_timezone, invalid_rrule (Recurring Date); invalid_location (Location); holes_not_allowed, too_many_polygons, invalid_coordinates, too_few_points, max_vertices (Area; max_vertices blocks the write); unsupported_location (a relation on a location it can't be stored on).
  • Controls: dry_run, batch_id, strict: true (warnings become errors), if_match (hash over stored values and core properties; refused together with ids). Writing a field value doesn't change post_modified; use the hash to detect concurrent edits.
  • Undo: restore_values descriptors carry the previous values of exactly the fields (or properties) written; past 20,000 bytes the largest of them (values, or a long content or description) is stored with the activity entry and the descriptor names vx-framework/undo-change instead, and past the payload budget the undo is none (sizes in Activity log and undo). create-post → delete-post (trash); update-post / update-term → same ability with previous props; set-post-status / trash → previous status; force delete and delete-term → none; create-term → delete-term (permanent).
  • Permissions: the only check is manage_options; no edit_post / publish_posts per object and no post-lock check. Count first with vx-framework/count-posts / vx-framework/count-terms / vx-framework/count-users.
  • Different values per post: one vx-framework/set-post-values step per post inside vx-framework/apply-changes (≤ 25 steps).

Documentation for the VX Framework.