Updating post meta at scale requires PHP
You want to add a featured_on_homepage flag to 50 posts matching a pattern. WordPress's Custom Fields UI lets you do one post at a time. For bulk, you're back to update_post_meta() in PHP — which means writing a script, running it once, then deleting it.
Worse, update_post_meta has no safety net. Typo a key like _edit_lock and you can corrupt post storage. Typo _wp_page_template and you break the template assignment.
What most people do instead
A better way: one command, protected keys blocked
Run update post meta with -post_id, -key, and -value. Inside a macro, loop over filter-post results with for_each. Protected keys (_edit_lock, _wp_page_template, _wp_attached_file) are blocked — so a typo can't corrupt post storage.
Safety rail baked in. Protected keys (_edit_lock, _wp_page_template, _wp_attached_file, _wp_trash_meta_time) are blocked. A macro accidentally pointed at a protected key fails gracefully instead of corrupting the post.
How it works
Wraps update_post_meta with validation. If -post_id is omitted, uses the current post context (when available). Protected keys return an error before the meta write happens.
| Parameter | Value |
|---|---|
-post_id | Target post ID. Empty uses current post context. |
-key(required) | Meta key (not a protected core key) |
-value(required) | Meta value (string, number, or serialized data) |
| Protected keys | _edit_lock, _edit_last, _wp_page_template, _wp_attached_file, and others — blocked |
| Can be used in |
Real example
You launched a new SEO strategy. Every post over 2000 words should get a seo_long_form flag so your theme template can render a table of contents for them.
Macro: filter post -status=publish -min_length=2000 → for_each: update post meta -key=seo_long_form -value=1. One run flags every long-form post. Your theme template renders TOCs from the flag without you touching a single post.