Add tags/categories to a WordPress post from WP-CLI


Staff member
I have a bash script that posts to WordPress. It does this fine, but I want to have it add tags to the posts. It uses <a href="" rel="noreferrer">WP-CLI</a> and there doesn't seem to be a way to add tags to a post from it.

To clarify, I'm talking about post tags, not HTML tags.
Also, this bash script is being run on the same server that is hosting the WordPress site.

I also found <a href="" rel="noreferrer"></a>, however it doesn't seem to have a tag feature either.

From what I've read, I think I would be able to accomplish what I want using XML-RPC in some way, but I know almost nothing about it.

Here's the WP-CLI command I've been using. Which works, but doesn't add tags.

wp post create --post_title="This is the title" --post_content="This is the post" --post_status=future --porcelain

In desperation, I tried adding
--post_tags="these are tags"
, but it didn't work. I've been searching for the answer for days now.

I just want to be able to make a WordPress post, with tags and a category, from a cronjob. I'm familiar with bash, so that would be best, but if you know of any solutions using other languages, that's welcome also.