• Hi,

    How can I rename an API route item eg. “id” to “postid” or when using the _embed option the field “wp:featuredmedia” to “featuredmedia”?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @diplatis

    If I understand your query correctly probably, you are looking for adding/registering a custom endpoint for an API in your application.

    In order to define custom endpoints, write a plugin method and attach it with action hook ‘rest_api_init’.
    Hope this helps to sort out your query. All the best! Happy Programming!

    Regards.

    Thread Starter diplatis

    (@diplatis)

    Hi,
    no, I don’t want to add/register a custom endpoint, I want to rename a field name from a built-in API endpoint.

    Moderator bcworkz

    (@bcworkz)

    I think what Aashish is saying is you cannot rename core parameters. In order to use custom parameters, you need to define your own route/endpoint. If that was Aashish’s intent, I concur.

    @bcworkz yes you are correct my thought was similar to what you have stated. We cannot rename core parameters in a build-in API endpoint.

    Thank you for sharing your inputs.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Rename API route item’ is closed to new replies.