Skip to content

Commit ad11a0b

Browse files
Document how to import an attachment and assign multiple thumbnails
1 parent 816c024 commit ad11a0b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

commands/media/import/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)