Wp-cli: --post_category="not working"

Created on 9 Jan 2018  Â·  3Comments  Â·  Source: wp-cli/wp-cli

I am trying to set a post category in post creation with the following
wp post create --post_type=post --post_title="asdf" --post_status=future --post_category="Teste" --post_content="asdf" --porcelain --allow-root --path=/var/www/html everything works fine except for --post_category.

Does wp-cli have this functionality to assign posts?

bug post-create post-update good-first-issue command documentation

All 3 comments

@killown Can you try using the ID of the category to assign it? That should work.
According to the documentation, using name or slug should work as well, but it didn't for me with some quick tests.

Yes for hierarchical taxonomies such as categories need to give ids due to this wp-includes/post.php#L4131 check casting the array to ints.

So need to update the docblock, and check and give warnings (errors?) if given non-int category ids., for both post create and post update.

Thanks for raising the issue @killown !

Edit: as an enhancement, we could look up and resolve the category names/slugs, which would be nice.

this worked after you tip: wp post term set 1000 category test --allow-root --path='/var/www/html' thanks a lot

On Jan 10 2018, at 7:37 pm, gitlost notifications@github.com wrote:
>

Yes for hierarchical taxonomies such as categories need to give ids due to this wp-includes/post.php#L4131 (https://github.com/WordPress/WordPress/blob/master/wp-includes/post.php?recipient=reply%2B00005f855e0cdd6dbe7bcf037a6f36511e9d55abde806b8b92cf00000001166e49aa92a169ce111c4756%40reply.github.com#L4131) check casting the array to ints.

So need to update the docblock, and check and give warnings (errors?) if given non-int category ids., for both post create and post update.

Thanks for raising the issue @killown (https://github.com/killown?recipient=reply%2B00005f855e0cdd6dbe7bcf037a6f36511e9d55abde806b8b92cf00000001166e49aa92a169ce111c4756%40reply.github.com) !

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (https://github.com/wp-cli/wp-cli/issues/4605?recipient=reply%2B00005f855e0cdd6dbe7bcf037a6f36511e9d55abde806b8b92cf00000001166e49aa92a169ce111c4756%40reply.github.com#issuecomment-356744861), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABfhcxoJWTooU3TR_24Kdxo_9GxJilCks5tJS2qgaJpZM4RXug0?recipient=reply%2B00005f855e0cdd6dbe7bcf037a6f36511e9d55abde806b8b92cf00000001166e49aa92a169ce111c4756%40reply.github.com).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jjtroberts picture jjtroberts  Â·  3Comments

vercotux picture vercotux  Â·  3Comments

fwaggle picture fwaggle  Â·  3Comments

yratof picture yratof  Â·  3Comments

schlessera picture schlessera  Â·  4Comments