1

I'm using the WP CLI and WP REST API.

To create a post I use:

$ wp post create --post_type=page --post_title='title-of-page' --post_status=publish

I need a field in the REST API which I added via the functions.php file in my wordpress theme:

function createField() {
  register_rest_field('page', 'rows', array(
      'get_callback' => function() {
        return "this part works.. kinda";
      }
  ));
}

enter image description here

The field shows up fine in the API.

The problem: The value of the field rows is always the same because it's set via functions.php. I want to set it (or overwrite, doesn't matter) via terminal when creating the page with wp cli (or after when selecting the page by ID).

Any solution would be appreciated, doesn't have to be wp cli. Preferably with the terminal though!

0 Answers0