Registering default values for meta data

With WordPress 5.5, the register_meta() functions ( including register_post_meta() ) now support registering default values. Previously it was only possible to register default values for the REST API schema like this:

register_meta( ‘post’, ‘greeting’, array( ‘single’ => true, ‘type’ => ‘string’, ‘show_in_rest’ => array( ‘schema’ => array( ‘type’ => ‘string’, ‘default’ => ‘hello’, ), ), ) );

However, this would only be applied to calls made from within the REST API – calls to get_post_meta() would not use this default value. Now it is possible to pass in a default value that will be applied to all calls to any of

This post was originally published on this site

Work With Xiphos Web Marketing

No business is too small to succeed, thanks to online technology! From marketing, to customer service, to placing orders, to customer financing, there are tools that anyone can utilize. Let me, Nate Houstman, be your guide!


Pin It on Pinterest

Share This
Xiphos Web Marketing