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 sidebar list shows the sidebars your theme registers

CLI
~/tips/tip-wordpress-wp-sidebar-list-inactive

wp sidebar list

Lists the registered sidebars with their IDs, which you need for other widget commands.

The widget commands all want a sidebar ID, and I never remember what a theme calls its sidebars. This command prints them.

wp sidebar list

By default you get name, id and description. The docs also list optional fields: class, before_widget, after_widget, before_title and after_title. The last four hold the HTML wrapper strings of the sidebar.

wp sidebar list --fields=name,id --format=csv

The docs show it like this:

name,id
"Widget Area",sidebar-1
"Inactive Widgets",wp_inactive_widgets

The ID column is what you hand to wp widget list. The formats are table (the default), csv, json, ids, count and yaml.

The caveat is --inactive, which lists only inactive sidebars. According to the docs it is not in a stable WP-CLI release yet. To use it you need the nightly build:

wp cli update --nightly
wp sidebar list --inactive --fields=id --format=csv

I’d only switch to nightly on a test site. For a normal check the plain command is enough.

Once you have the ID, the docs show wp widget list sidebar-1 --fields=name,id --format=csv, which prints one line per widget in that sidebar, for example search,search-3. The widget list command accepts the same --fields and --format options.

Further reading: wp sidebar list

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link