1

When I try to create a new post with accents width wp-cli (in windows 10 command, I got latest wp-cli)

wp post create  --post_title="Héllo" --post_type=page --post_content="Héllo world"

I got error:

"Impossible to insert this post in database"

It works fine when I replace the "é" by "e"

wp post create  --post_title="Hello" --post_type=page --post_content="Hello world"

Any idea ?

  • i didn't use WPLI but the issue relates to sanitization, your data should be sanitized, and indeed there is a way to sanitize insertions, search for it or I hope anyone can post an answer – Makiomar Aug 12 at 13:38
1

See Cannot create a post with Latin characters in the title on Windows.

Using UTF-8 in PHP arguments doesn’t work on Windows for PHP <= 7.0, however it will work for PHP >= 7.1, as it was fixed as part of Support for long and UTF-8 path. A workaround for PHP <= 7.0 is to use the --prompt option:

echo "Perícias Contábeis" | wp post create --post_type=page --post_status=publish --prompt=post_title

It looks a bit as if this bug only affects the title. Have you tried that? And the post content doesn't matter? Then the following should work:

echo "Héllo" | wp post create --post_type=page --post_content="Héllo world" --prompt=post_title
  • It affects title and also content – yarek Aug 12 at 16:13
  • @yarek – Dayum! Then you'll need to do quite some Bash voodoo to get this running in a one-liner. – leymannx Aug 12 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.