Skip to content

Posting from the commandline

This post has been created using the commandline.

$ cd $WP_ROOT
$ wp post create /tmp/post-content.txt \
> --post_title="Posting from the commandline" \
> --post_category=16 \
> --post_status=publish

You will find additional information in $WP_ROOT/wp-includes/post.php.

Look at the parameters for “function wp_insert_post”. They translate into command line parameters for “wp post create”.

Also look at the various “register_post_status” definitions in that file if you want to understand what ‘publish’ is and which other states exist.

The category has been specified as a number. You can find these in the menu for the category tree. Category labels like “blog” don’t work here.

Published inBlog

3 Comments

  1. Tobias Klausmann

    Love the >

    • kris kris

      Fixed. If you touch up the post in visual editor instead of text editor (i.e. to fix line breaks), the > are being replaced by entities. Didn’t know that.

Leave a Reply

Your email address will not be published. Required fields are marked *