wp-cli post create & media import issues
-
Been using wp-cli which I love. But i’m trying to create new posts w/ a clickable image, but the best wp-cli does with 1 command is a featured image which is not clickable (plus featured images are above my post’s title & content).
This command is supposed to create a post w/ image, but instead it’s an empty post (in the backend the image is “uploaded” to the post, but the image is not displayed):
wp media import ./FILENAME --post_id=$(wp post create --post_title='TITLE' --post_status=publish --porcelain)
Is there a fix or a missing option?
So now I’ve moved on to 2 commands: Creating the post & then updating the posts’ content field/value.
wp post update <ID> --post_content="<a href=""URL-TO-IMAGE""><img class=""size-full"" src=""URL-TO-IMAGE"" /></a>"
The problem with this is that I have to rearrange a bunch of values, so after I run this:
wp media import FILENAME
I’ll need to do this:
echo `wp option get siteurl`/wp-content/uploads/`date +%Y`/`date +%m`/FILENAME
and so on
I’m running latest wp-cli & wordpress with the default plugins, so maybe I’m missing a plugin? Thanks.
- This topic was modified 7 years, 2 months ago by . Reason: fixed code quote
- This topic was modified 7 years, 2 months ago by . Reason: added double backticks to escape backticks
- This topic was modified 7 years, 2 months ago by . Reason: 5 backticks for 1 backtick
- This topic was modified 7 years, 2 months ago by . Reason: using ` as backtick
- The topic ‘wp-cli post create & media import issues’ is closed to new replies.