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 comment approve clears the WordPress moderation queue in one command

WordPress
~/tips/tip-wordpress-comment-approve-pending

wp comment list --status=hold --fields=comment_ID,comment_author,comment_content

Approves all pending comments at once after you have checked the list.

The Comments screen makes you approve things page by page. When you know the queue is clean, the terminal is faster.

Look first:

wp comment list --status=hold --fields=comment_ID,comment_author,comment_content

hold means waiting for moderation. Read through the list. When everything in it is fine, approve the lot:

wp comment approve $(wp comment list --status=hold --format=ids)

--format=ids prints the IDs separated by spaces, and wp comment approve takes any number of them. For a single one, give the ID: wp comment approve 1337.

The opposite exists too. wp comment unapprove puts a comment back in the queue, and wp comment spam moves it to the spam folder.

The risk is in the gap between looking and approving. If a new comment comes in after you read the list, the second command approves it unseen, because it asks for the queue again. On a busy site, I’d copy the IDs from the list you actually read and approve those instead of the subshell.

Further reading: wp comment approve, wp comment list

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link