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

Confused about AngularJS and WordPress

Unfortunately I don’t know Angular to give you a hand with that, but I’m seeing this question is related to another about consuming an endpoint with a filter by meta_key (by the way, I’ve updated my previous response with a very simple jQuery-only code to show posts retrieved in a list). However, if you don’t … Read more

Problem on creating custom endpoints for REST

Writing a custom endpoint is not hard at all. Your code goes to your theme’s functions.php file, or a plugin. After you register a REST route, you can access it via this URL: www.example.com/wp-json/myplugin/v1/foo Also I assume you are missing \ in your callback function’s parameters, as it should be \WP_REST_Request $request.

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