Skip to content
0

katanakit-js / WpEmbedded

Type Alias: WpEmbedded ​

ts
type WpEmbedded = z.infer<typeof WpEmbeddedSchema>;

Defined in: src/types/index.ts:1316

Embedded resources returned by WordPress when _embed is used.

Contains related entities: author, featured media, terms, replies. Access with post._embedded?.["wp:featuredmedia"]?.[0].

Example ​

ts
const result = await useWpGetPosts({ _embed: "author,wp:featuredmedia" });
if (result.ok) {
  for (const post of result.data) {
    const author = post._embedded?.author?.[0]?.name;
    const image = post._embedded?.["wp:featuredmedia"]?.[0]?.source_url;
  }
}

Released under the MIT License.