Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add block content via the --post_content flag #490

Closed
2 tasks done
helgatheviking opened this issue Mar 29, 2024 · 4 comments
Closed
2 tasks done

Cannot add block content via the --post_content flag #490

helgatheviking opened this issue Mar 29, 2024 · 4 comments

Comments

@helgatheviking
Copy link

helgatheviking commented Mar 29, 2024

Bug Report

Describe the current, buggy behavior

Cannot add block content via the --post_content flag.

Describe how other contributors can replicate this bug

Try to create a post with block content

wp post create --post_title="Pizza Day" --post_status=publish --post_content="<!-- wp:paragraph --><p>PIZZA FRIDAY</p><!-- /wp:paragraph -->"

See error that the event is not found.

bash: !-: event not found

However

wp post create --post_title="Pizza Day" --post_status=publish --post_content="PIZZA FRIDAY"

inserts a post, though with "classic editor" content that then needs to be converted to blocks.

Hopefully this is just bad formatting on my part? In which case, we can switch this to a documentation request?

Describe what you would expect as the correct outcome

post inserted with block content ready for use in the block editor

Let us know what environment you are running this on

OS:	Linux 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php8.0
PHP version:	8.0.30
php.ini used:	/etc/php/8.0/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 15.1 Distrib 10.5.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/var/www/subdomain.mywebsite.com
WP-CLI packages dir:	/home/leftback/.wp-cli/packages/
WP-CLI cache dir:	/home/leftback/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.7.1

@ernilambar
Copy link
Contributor

This seems to be the issue with shell rather than WP CLI. Even echo "<!-- wp:paragraph --><p>PIZZA FRIDAY</p><!-- /wp:paragraph -->" gives that error. ! character is expected to be escaped. When you escape such character in the command, it works as expected.

wp post create --post_title="Pizza Day" --post_status=publish --post_content="<\!-- wp:paragraph --><p>PIZZA FRIDAY</p><\!-- /wp:paragraph -->"

@helgatheviking
Copy link
Author

helgatheviking commented Apr 1, 2024

I just tested your command in the CLI and it runs without error, however the content created is still not a block but the classic content. The escaped comment is still considered a string.

image

Found [this issue] which suggests importing escaped content via HTML file. don't know if I'll be able to do that in the blueprint.json, but I will try to test.

@ernilambar
Copy link
Contributor

Above command is working fine for me. I am using WP-CLI 2.10.0.
Screenshot 2024-04-02 at 11 41 42 AM

@danielbachhuber
Copy link
Member

Let's continue the conversation in wp-cli/wp-cli#5923 (comment)

@danielbachhuber danielbachhuber closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants