Sign inBlogSupportContact
Content

Write WordPress post meta safely from the admin

Update custom fields, SEO meta, WooCommerce product attributes. Protected keys blocked automatically. One macro step can update 200 posts.

4 min read May 2026 update post meta

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

Write one-off PHP scriptsPaste snippet, run once, delete. No safety net against typo'd protected keys.
Edit each post manually via Custom FieldsDoesn't scale beyond a handful of posts. Custom Fields is disabled by default on new WP.
Install ACF and write logic in functions.phpHeavy. Another admin-page subscription. Still requires PHP for bulk updates.

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.

TrueCommander
Post meta updated
Post #247
Key: featured_on_homepage
Value: 1
Protected-key check: passedsafe

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.

1
Provide post_id, key, valueOr omit post_id to use the current post context
2
Protected-key check runs firstCore WP keys are blocked. Custom keys pass through.
3
Loop with for_each for bulk updatesCombined with filter-post, update 200 posts in a single macro run.
ParameterValue
-post_idTarget 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.

Goes further with TrueCommander

Ready?

Write post meta at scale. Safely.

This is one of 91 commands. All included with every license.

Cookies. The short version.

Essential cookies keep the cart and theme working. Analytics only fire if you say yes. Read our policy.