0

Given

$title = "This is the title of a post";

I want to cURL the API and get the post ID. With v1 you could use the [filter] parameter, but that no longer works.

There is a similiar question: https://stackoverflow.com/questions/33131103/wp-rest-api-get-post-by-title

My question is: Can anybody tell me an easier way to do this?

My research:

I guess you could hit this URL:

Which would give you the first 99 results, including the titles. But you'd really have to ping every post on the site to get the correct answer. It's possible there are duplicate posts with the same title, which may be of interest. By default, the maximum number of results is 99, and you can't change that on an external site. So you are required you to do 1 http request for every 100 posts on the site, total. 50 separate requests for a site with 5000 posts. I don't think you can set the number of results higher than 99 on an external site [am I wrong?]. I'm not sure I understand the rationale for this, but you can't execute a query on the remote server anymore, or at least you can only search by their top-level parameters. Title isn't one of the paraments.

If anyone wants to help, there should be a PHP cURL example and a Javascript example. I want the PHP one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.