Fetching WP.me shortlinks for posts using WP Rest API

This has been resolved by registering a new field in the rest api using the following functions. add_action( ‘rest_api_init’, ‘sam_add_custom_rest_fields’ ); function sam_add_custom_rest_fields() { $sam_short_link_schema = array( ‘description’ => ‘Short Link’, ‘type’ => ‘string’, ‘context’ => array( ‘view’ ) ); register_rest_field( ‘post’, ‘samad_short_link’, array( ‘get_callback’ => ‘sam_get_short_link’, ‘update_callback’ => null, ‘schema’ => $sam_short_link_schema ) ); … Read more

Can we validate data from jquery

Yes, you can validate data using jquery before submitting form. There is a way custom way to do that by checking the fields value length `$(document).ready(function(){ $(“#form”).submit(function(){ var field_value = $(‘input[name=”some_name”]’).val(); if(field_value.length>0){ return true; } else{ return false; } }); });` Or you can use a jquery validation library. https://jqueryvalidation.org/