B
B
bbeight2017-03-11 01:48:53
JavaScript
bbeight, 2017-03-11 01:48:53

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

2 answer(s)
M
Maxim, 2017-03-11
@bbeight

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.

V
Vasya Petrov, 2017-03-11
@VasyaPertrov

I don't understand how to open the whole post when I click on read more

read more is displayed on archive pages in 2 cases.
1. When the_excerpt is displayed in the content archive template .
2. When the_content is displayed , but the tag is inserted into the content itself <!--more-->.
The full post is displayed in the single post template with the same the_content.
Materiel according to templates .
No more complex dives in the API and the invention of bicycles with square wheels are required.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question