Last active
October 28, 2018 21:51
-
-
Save craigiswayne/c286de288e2c328665bd7f193fca74f8 to your computer and use it in GitHub Desktop.
Create WordPress Posts with Featured Images from WP-CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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