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
)
);
}
function sam_get_short_link( ) {
return wp_get_shortlink();
}
This will create a new field named “samad_short_link” in the rest api
Related Posts:
- WP Rest API: details of latest post including featured media url in one request?
- run silex or slim with wordpress
- WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?
- When would it make sense to use Jetpack?
- How to tell if Jetpack’s Photon is active?
- How to create gutenberg block using REST API independently or as headless way?
- Filter out results from REST API
- How to authenticate custom API endpoint in WooCommerce [closed]
- WordPress pods io – Rest API for fetching fields information for custom post type
- Reduce nonce lifespan
- Add Products to user’s ID Woocommerce
- Store post in raw markdown format, no html?
- REST-API: extend media-endpoint
- Keep user’s privileges on accessing contents in JSON response
- How to retrieve custom meta term of category taxonomy from WP Rest API?
- How to stop xmlrpc attacks without disabling component to allow JetPack to work in WordPress?
- I am getting error message on accessing menu-endpoint
- Detect permalinks when passing querystring in REST API requests
- How to save generated JWT token to cookies on login?
- How to modify WCMP Rest API response?
- wp_remote_get() returns 403 while file_get_contents() does not
- Ability to make API calls out of WordPress as well as executing SQL?
- Limit post creation by role
- Ajax with plugins returns 0
- Set plugin-values when creating post via REST-API
- AFNetworking incorrectly interpreted WP_Error
- Filtering get_permalink in Jetpack / ShareDaddy
- Redirect to another page using contact form 7? [closed]
- Access WP_REST_Server from within plugin namespace
- REST route from a plugin not working if WordPress is installed in a subdirectory
- Plugin retrieving results even after uninstallation
- WordPress REST API Plugin Development – Add Custom Endpoint
- Is it possible to remove subscription box from Jetpack stats page? [closed]
- Cropping images from top center using Jetpack Photon
- Edit / Change Jetpack Mobile Theme [closed]
- How to create WordPress custom end point with multiple parameters?
- How to execute plugin and theme updates from a web hook / endpoint?
- REST API can’t get the response manually
- Moving Jetpack buttons to appear below the first H2 title on all project/post pages [closed]
- How to integrate together a website currently hosted WordPress.com and a custom web application currently hosted on Azure?
- WP Rest API and json_decode()
- WordPress /users/me endpoint request forbidden
- Facebook and Twitter share buttons not working [closed]
- WordPress Stats Plugin: Display Post Views [closed]
- Why may one avoid Jetpack plugin? [closed]
- After installing JetPack, can I delete the WordPress stats plugin?
- Seperate plugin and theme files
- Change Dashboard URL from wp-admin to wp-admin/index.php
- wc_get_template_part doesnt display the content [duplicate]
- I’m receiving the following error using the below code: Uncaught Error: Cannot use object of type WP_REST_Response as array
- Show views count for pop up post
- How to send SMS notification to customer after click on submit?
- How to send the featured image of a post to an API?
- How to authenticate via API to allow writes/updates
- Do i need to use a plugin for third party api integration?
- One WooCommerce Store to multi distributor sites
- Custom REST API POST Endpoint Not Working, 404 Error
- Getting all woocommerce products from REST API call in plugin
- add tags to wordpress post using REST API
- WordPress output data to another website and pull data
- Hide response returned from WordPress REST API call
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- How achive serving multiple concurrent Ajax / Rest calls in plugin?
- CRUD from WordPress to Business Central 365 through OData REST API
- WP Rest Api GET method restriction on route, but POST method also works
- Showing how many times is plugin activated or deactivated
- Modifying server’s response to API endpoint
- How to get data from a private API and add it to wordpress pages
- Fetching users data from REST API
- Consume legacy rest api dependent upon WP API plugin
- custom REST endpoint not passing body of POST request to callback
- How can I disable Jetpack plugin on mobile?
- Upload image to wordpress using ionic/cordova with WP REST API V2
- Sending post data over REST API, how to parse shortcodes in post_content?
- How to do rest APi with wordpress
- Jetpack Comments Change Placeholder Text
- Extend WordPress REST API with Scheme Pro Plugin
- I’ve installed Jetpack but can’t edit the CSS to my blog?
- how to know that a wordpress plugin support using API?
- Questions about using Disqus or Jetpack for comments [closed]
- wordpress Ajax success doesn’t return the value
- How can I send api calls from my plugin?
- Filter custom post type returned from REST api
- My wp_update_nav_menu action is firing twice
- Update post meta Rest Api
- Social login authentication via wordpress rest api
- Is option_active_plugins actually doing anything useful?
- WordPress REST API filter on blank custom ACF
- Is it possible to create post in wordpress using postman?
- How to update a lot of posts on my WP site with additional content?
- how to update WordPress plugins from external website with nodejs?
- Block Root REST API Route using custom &/or iThemes
- Accessing Correct Database to Create REST API Endpoint
- Is it a good idea to restrict the REST API
- REST API – filters not working inside plugin class
- i need to resive data external api and show user
- Can The REST API be used to create/edit plugins and themes?
- How prevent STDOUT of Plugin_Upgrader->upgrade(…)?
- Get list of outdated plugins in the rest api?
- Long running tasks in a plugin: wp-cron vs REST API callback [closed]