How to load Nav items data after fetching WordPress Menus

Hi there,

I’ve followed this lovely tutorial on how to fetch the WordPress Menus in Frontity.

I’m returning a menu called ‘featured-post’ which has one item: a post with a id of 70, it’s title, URL, etc. No problems returning the menu JSON or anything.

However, I also need to get that posts image and excerpt, which is not found in the menu JSON. That post is also not found in state.source.posts - so I’m wondering how exactly I can fetch that post’s data, in the most efficient way possible?

Thanks in advance!

You would need to do a 2 step process where you fetch the post as well.
I believe if you use _embed, as a param when fetching, frontity will automatically populate the state also with the featured image.

As for the most efficient way possible, I would say that is the fetch from wp-source. @frontity/wp-source - API Reference
You have the link already so that should not be an issue

Good luck. Hopefully this helps.

1 Like

Thanks so much, very helpful!

1 Like