How to post an unserialized array via wordpress rest API as meta data

So I found my own answer, fave_property_images is not supposed to be an array, its just multiple strings. Therefore the following codes in function.php fixes the problem. function add_fave_property_images() { register_rest_field(‘property’, ‘fave_property_images’, array( ‘get_callback’ => ‘get_property_images’, ‘update_callback’ => ‘update_property_images’, ) ); } function get_property_images( $object ) { //return the post meta return get_post_meta( $object[‘id’], ‘fave_property_images’, … Read more

What is the meta field in the response of the user REST API?

Look into register_rest_field() to register meta with the rest api. add_action( ‘rest_api_init’, ‘adding_user_meta_rest’ ); function adding_user_meta_rest() { register_rest_field( ‘user’, ‘collapsed_widgets’, array( ‘get_callback’ => ‘user_meta_callback’, ‘update_callback’ => null, ‘schema’ => null, ) ); } And then put your get_user_meta bit in the callback. function user_meta_callback( $user, $field_name, $request) { return get_user_meta( $user[ ‘id’ ], $field_name, true … Read more

Cannot DIsplay a Snackbar Notice on Button Click – Notice is undefined

I figured it out. The component was not rerendering, when clicking the “Save” button. I included the compose component in the render method and all is working good now: const Notices = ({ notices, removeNotice }) => { const snackbarNotices = notices ? notices.filter((notice) => notice.type === ‘snackbar’) : []; return ( <> <SnackbarList className=”cwg-admin-notices” … Read more

Post API tax_relation field doesn’t work

So it turns out this was completely changed in 5.7 and the documentation has, unhelpfully, not been updated to reflect that. More info in the Git commit. Instead of: /wp-json/wp/v2/posts?tags=22,23&tax_relation=AND This URL works: /wp-json/wp/v2/posts?tags[terms]=22,23&tags[operator]=AND

Get more than one author’s posts with REST API

The author parameter in your request, seems to be mapped to the author__in parameter in WP_Query that runs behind the rest-api call here, where a comma separated input: /wp-json/wp/v2/posts?author=1,5 is translated to an array( 1,5 ) input for author__in.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)