brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp post meta list shows every custom field of one post

Database
~/tips/tip-wordpress-post-meta-list

wp post meta list 123

Prints all custom fields (post meta) of a single post, optionally filtered by key.

When a plugin stores something on a post and the post does not look right, I want to see its raw custom fields. The database is a detour, and WP-CLI prints them directly.

wp post meta list lists all metadata of a post by its ID. The default fields are id, meta_key and meta_value.

wp post meta list 123

Limit it to some keys with --keys and pick the output with --format (table, csv, json, yaml or count):

wp post meta list 123 --keys=_thumbnail_id,_wp_page_template --format=json

A lot of plugin data is serialized PHP, which is unreadable in a table. The --unserialize flag unserializes the meta_value output:

wp post meta list 123 --unserialize --format=json

Sorting works with --orderby (id, meta_key or meta_value) and --order, and --fields limits the columns:

wp post meta list 123 --fields=meta_key,meta_value --orderby=meta_key

Find the ID first with wp post list --fields=ID,post_title. Reading is harmless. The neighbouring wp post meta update is not, so export the database before you use it on a live site.

The output can contain private data, such as form submissions that a plugin stores. Look before you paste it anywhere.

Further reading: wp post meta list (WP-CLI handbook)

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link