Getting the Wordpress source to work

Hey,

First of all, sorry as I’m a total newbie in this but absolutely love this project. Trying to get it working but somehow none of the possible source URLs do not seem to work - they just give a 404 when I change the original link https://test.frontity.io/wp-json/ to it. We got a pretty simple page with a separate blog part (so a static front page with non-blog content and a separate section on the site with blog content).

The links we’ve tried have been https://www.nextgaything.com/wp-json/wp/v2/ as well as https://www.nextgaything.com/wp-json/wp/v2/posts/.

Any help would be appreciated.

1 Like

Same here. The index homepage works fine but soon as you click on a post link, it goes 404

Click on any link and it goes :frowning:

Also, I would like to know how to get the featured image of a post to show in the list-item.js

I tried this

const fmedia = state.source.featured_media[item.featured_media];

but it causes an error.

Seems like this is causing the issue

Lets wait for an update.

Hello @jarmo it looks like your REST API is not accessible.
37

It is possible that either your hosting or either some plugin has blocked it. Can you please take a look at it?

@sonicares could you please let us know the url of your API? We’ll take a look to see what may be wrong.

1 Like

Hi,

You’re totally right - a plugin had banned it for non-admin users. But now that setting is removed and verified with Postman. Still the same issue somehow.

Hey. its

https://thehooksite.com/

Its not my site. Just some random wordpress site I found for testing. lol

Hi, @jarmo!

The URL you have to use is https://www.nextgaything.com/wp-json as it’s the root of the REST API.

If the problem persists, it can be the links don’t have a structure that matches one of the default patterns of wp.org for permalinks.

For now, we’re going to give support to the patterns below, but we want to make it easy to use any kind of pattern in the future:

However, there is a bug we must solve first.


Hi, @sonicares!

The problem could be just the one that I just mentioned so try again when it has been fixed! (P.S. You will have to execute npm install to update to the last version).

The way to get media images is using state.source.attachment so you should use

const fmedia = state.source.attachment[item.featured_media];

If you have any other doubts or questions, feel free to ask!

4 Likes

The fix has been released. Please update @frontity/wp-source to the latest version with:

npm install @frontity/wp-source@latest
1 Like

Thankyou. I am trying to use this by

{fmedia.rendered}

but its giving me an error. How do I display this image?

You can explore the data using frontity.state in the console of your browser, like this:

The data structure you are going to find in frontity.state.source is the same you can find in the REST API. For example, this is an attachment:
https://www.nextgaything.com/wp-json/wp/v2/media/567638
And you can see it in your state using: frontity.state.source.attachment[567638].

With attachments you usually want to use source_url or the info inside media_details.sizes.

1 Like