Lets say my query look something like this:
WP_Query( array(
'post_type' => 'milkshakes',
'posts_per_page' => 1,
)
And lets say there are 20 milkshakes. How can I return only the milkshake from page 5?
I'm asking because I'm creating a REST API endpoint and I'm looking to recreate ?page=5.
WordPress provides REST API you can use them, It come with a very good documentation. https://developer.wordpress.org/rest-api/
To return only the milkshake from page 5, pass paged parameter.
WP_Query( array(
'post_type' => 'milkshakes',
'posts_per_page' => 1,
'paged' => 5
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.