Skip to content

Instantly share code, notes, and snippets.

@craigiswayne craigiswayne/script.sh
Last active Oct 28, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.