I have recently installed Jetpack for my self-hosted blog. I have already installed the WordPress REST API plugin to fetch blog contents.

After installing the Jetpack, the default WordPress short link (?p=id) has been replaced by wp.me/somechars. However, when I try to fetch the wp.me short links in the rest API, it is showing the default WordPress short link

How can I include wp.me short links on wp rest API?

  • report a bug/feature request to jetpack – Mark Kaplun Apr 28 '17 at 5:40
  • Hello @MarkKaplun I read somewhere that we can display this meta in REST API by removing it from the private tag. Something called custom end points, but not sure how to do it for wp.me shortlinks!! – Abdu ssamad Apr 28 '17 at 5:51

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' )

            '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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.