File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ display_global_parameters: true
4646 # Import a local image and set it to be the post thumbnail for a post
4747 wp media import ~/Downloads/image.png --post_id=123 --title="A downloaded picture" --featured_image
4848
49+ # Import a local image, but set it as the featured image for all posts
50+ # 1. Import the image and get its attachment ID
51+ * 2. Assign the attachment ID as the featured image for all posts
52+ ATTACHMENT_ID="$(wp media import ~/Downloads/image.png --porcelain)"
53+ wp post list --post_type=post --format=ids | xargs -0 -d ' ' -I % wp post meta add % _thumbnail_id $ATTACHMENT_ID
54+
4955 # Import an image from the web
5056 wp media import http://s.wordpress.org/style/images/wp-header-logo.png --title='The WordPress logo' --alt="Semantic personal publishing"
5157
You can’t perform that action at this time.
0 commit comments