I'm trying to check by a post title if post exist or not. For some reason when i try something like:
http://domain.com/wp-json/wp/v2/posts?filter[post-title]=table
I want if post with the name table exist, to get the post, if not, get an empty response. But for some reason when post with title not exist i get all posts back. How could get empty when no post exist and the post when it exist.
If you want to use the Fetch API with WordPress, you simply have to call the fetch function in your JavaScript code. Follow that function with a . then handler to access the content. You can then display it on your website or in your web application.
To use the WordPress REST API, simply add /wp-json/wp/v2/posts to the end of your WordPress site URL. This will give you a list of posts (in JSON format). The default number of posts returned is 10, but you can choose to show more or less with the per_page argument — we'll talk about that below.
Unfortunately it is not possible, but you can use slug instead. Slug is editable part of the URL when writing a post and they can represent title of the page (or it can be changed into this).
http://example.com/wp-json/wp/v2/posts?slug=table
More details: https://developer.wordpress.org/rest-api/reference/pages/#arguments
According to http://v2.wp-api.org/, some have to use search
keyword :http://domain.com/wp-json/wp/v2/posts?search=table
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With