Skip to content

WpEmbedded

katanakit-js / WpEmbedded

type WpEmbedded = z.infer<typeof WpEmbeddedSchema>;

Defined in: types/adapters/wordpress.ts:183

Embedded resources returned by WordPress when _embed is used.

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

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;
}
}