WP-CLI lets you generate dummy posts with
wp post generate (doc). By default, these generated posts don’t include a featured image.
To assign a featured image to generated posts, you’ll need to pass the ids for the generated posts to
wp post meta update:
wp post generate --format=ids | xargs -0 -d ' ' -I % wp post meta update _thumbnail_id % <attachment-id>
<attachment-id> with the id for the image attachment you’d like to assign as the featured image for each post.
Deconstructing this example:
wp post generate --format=idsgenerates 100 new posts, and outputs the ids for those new posts.
|operator passes the results from
wp post generateto xargs, a utility which takes lines of input and passes them to some command.
xargs -0 -d ' ' -I % wp post meta update _thumbnail_id % <attachment-id>runs
wp post meta update _thumbnail_id <attachment-id>against each generated post, where
%is a placeholder for the post id and
<attachment-id>is the id for the image attachment you’d like to assign.