Answer the question
In order to leave comments, you need to log in
How to open post page in wordpress rest api?
I’m making a wordpress theme for myself on react, and I ran into a problem, I don’t understand how to open the entire post when I click on read more, namely, I don’t understand how to display exactly the post that I clicked on, help pliz, or maybe there are some lessons on wordpress rest api + javascript?
Answer the question
In order to leave comments, you need to log in
According to the documentation, to get the post, you need to call:
Actually, what's the problem?
Pass exactly that id to the request. If this is the question, then the id can be taken, for example, from the data-* attribute, having previously stuffed it there at the time of rendering all the posts on the page.
If the question is how to open it on a separate route, then you need react-router and a route like:
Then you will have the id of your article in this.props.params and you will be able to execute a GET request at the moment componenDidMount . Read more in the react-router documentation .
ps An article (ENG) on your question has recently arrived.
I don't understand how to open the whole post when I click on read more
<!--more-->
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question