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 generate fills a WordPress test site with dummy posts

WordPress
~/tips/tip-wordpress-post-generate-test-content

wp post generate --count=50

Creates any number of placeholder posts or pages to test a theme or a query.

A theme looks great with three posts. The real test is pagination, archives and a sidebar with fifty items in it.

wp post generate --count=50

That creates fifty published posts with placeholder titles. The defaults are 100 posts of type post with status publish. Change them with --count, --post_type=page, --post_status=draft and --post_date. For hierarchical types like pages, --max_depth=3 builds parents and children, which I think is a quick way to check that a page menu or breadcrumb copes with nesting.

The posts have no body by default. --post_content makes the command read content from standard input, so you can feed it a file with some real HTML:

wp post generate --count=20 --post_content < sample.html

Every generated post gets that same content.

To get rid of them later, --format=ids prints the new IDs when you create them. Save that output to a file and pass it to wp post delete when you’re done. Without it, test posts mix with your own and are a pain to pick out. Obviously, keep this away from a production site.

Further reading: wp post generate

Going deeper: Guide: let git bisect find the commit that broke your code

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