• I’m using the _embed option, but it makes the result very large in posts listing.
    How is it possible to shorten the result and only get the author and image in the _links and _embedded objects.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You can alter any REST response through the ‘rest_pre_echo_response’ filter. You’ll still get a very large response here, which you can pare down to your specific needs. The only thing changed is where the reduction occurs — server side instead of client side.

    Thread Starter Ahmad Sattout

    (@ahmadsattout)

    is there a guide on how to achieve this?

    Moderator bcworkz

    (@bcworkz)

    Using filter and action hooks in general is discussed in the Plugin Handbook.

    For specifically using the ‘rest_pre_echo_response’ filter, about all you can do is see where it’s applied in source code. Essentially, whatever your callback returns is sent to the requesting app.

    You can try searching the ‘net in general, but I’m under the impression this filter is not commonly used.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shorten REST Response with _embed’ is closed to new replies.