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
- Add quotes around exec argument This prevents 'Too many positional arguments' errors when the spaces are inside the arguments. See: https://github.com/wp-cli/wp-cli/issues/1928#issuecomment-12290190... — committed to primozcigler/wocker-cli by primozcigler 7 years ago
- Fix “Too many positional arguments:” The error may appear when title passed contains two words or wrapped within a quote. (https://github.com/wp-cli/wp-cli/issues/1928) — committed to tfirdaus/wp-locker by tfirdaus 6 years ago
- Merge tag 'v0.1.1' into develop - Shell helper to reset user group and permission - "Too many positional arguments", which may appear when title passed contains two words or wrapped within a quote. [... — committed to tfirdaus/wp-locker by tfirdaus 6 years ago
- Fix args handling in wp-cli script Related to wp-cli/wp-cli#1928 — committed to xemlock/wordpress-docker by xemlock 3 years ago
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
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