Skip to content

Instantly share code, notes, and snippets.

@craigiswayne
Last active October 28, 2018 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigiswayne/c286de288e2c328665bd7f193fca74f8 to your computer and use it in GitHub Desktop.
Save craigiswayne/c286de288e2c328665bd7f193fca74f8 to your computer and use it in GitHub Desktop.
Create WordPress Posts with Featured Images from WP-CLI
for i in {1..20}
do
post_type="post";
post_type_singular="Entrant";
post_title="$post_type_singular $i";
post_id=$(wp post create --post_author=admin --post_type=$post_type --post_status=publish --post_content="$post_title Content" --post_title="$post_title" --post_excerpt="$post_title Excerpt" --porcelain);
wp media import "https://picsum.photos/480/640/?random&$i.jpeg" --post_id=$post_id --title="Random Image for $post_title" --caption="$post_title Caption" --alt="$post_title Alternative Text" --desc="$post_title Desciption" --featured_image;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment