I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find nor in official documentation neither on Google. Thanks!
If you look at the code for the
create method, you'll see that it takes 2 parameters:
public function create( $args, $assoc_args )
$args doesn't seem to be used -
$assoc_args is the array passed to the
wp_insert_post function from WordPress core. The linked Codex page explains the array parameters.
In case you have many post to create, you can create a dedicated folder with all your posts as text documents, using
post_title as the txt file titles.
In this very same folder, create a bash file named
wp-post-create--loop-files.sh with the following :
#!/bin/bash FILES=*.txt for f in $FILES do echo "Processing $f file..." # TEXTFILE = $f # take action on each file. $f store current file name # cat $TEXTFILE wp post create "$f" --post_category=3 --post_title="$f" --user=3 done
Then you can create all your posts in a blink by executing