wp-cli: 'Too many positional arguments' with term create

I’m certain this is something to do with my setup, but I thought I’d ask for tips on how to fix it.

[mike@macster:BOILERPLATE]$ wp term create vendortax 'OneWord'
Success: Created vendortax 15.
[mike@macster:BOILERPLATE]$ wp term create vendortax 'Two Words'
Error: Too many positional arguments: Words
[mike@macster:BOILERPLATE]$ 


[mike@macster:BOILERPLATE]$ wp --info
PHP binary: /Applications/MAMP/bin/php/php5.5.26/bin/php
PHP version:    5.5.26
php.ini used:   /Applications/MAMP/bin/php/php5.5.26/conf/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 0.19.2

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 35 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I feel like the solution posted wasn’t clear enough if you got here from Google, so to help anyone else who may come across this issue, let me explain:

This issue in particular I believe was a WP-CLI bug, which was fixed, but you can still get this error on your own through user error. I was getting it when doing this:

Wrong: wp eval 'wp_set_object_terms('${POST_ID}', '${TERM}', "service_category");'

Correct: wp eval "wp_set_object_terms('${POST_ID}', '${TERM}', 'service_category');"

In single quotes (wp eval "these guys"), ${VAR}s are evaluated differently. It’ll split things up by spaces, giving that error. Hope this is accurate and hope this helps.

This fixed it

/Applications/MAMP/bin/php/php5.5.26/bin/php /usr/share/wp-cli.phar "$@"

Apparently the $@ need quotes. I wish I could remember where I found the page describing how to do this so I could see if I copied it wrong or if the instruction is wrong. in any case, it’s fixed now. Thanks for the help all!

Here it is http://www.gnu.org/software/bash/manual/bash.html#Special-Parameters

Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, “$@” is equivalent to “$1” “$2” ….