• Hi!

    So far, Better Search has been great, results are fast and posts returned are much more relavant. I’m running into an issue with AJAX however.

    After loading the first 10 posts on the search page, the user can load the next 10 posts by clicking a “Load More” button which hits queries a URL similar to: https://urlhere.com/wp-json/wp/v2/posts?page=2&per_page=10&search=videos”. Instead of the next 10 posts, however, this endpoint returns an empty array.

    After quite a bit of testing, I realized the “search” argument breaks the endpoint. During more tests, I noticed the route “/wp-json/wp/v2/search” works, but again, if you enter a search argument e.g. “../v2/search/?search=videos”, it breaks. Oddly enough, “../v2/search/?search=” works.

    Disabling the Better Search plugin returns all endpoint functionality to normal.

    Help please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    If you set page to 1 do you get the same results as you would if you were using the website to search?

    I’m definitely sure that the plugin is picking up when the /?search is pulled, but what confuses is me why per_page is not respected. I know the REST API specifies to use per_page, but does this by any chance work with posts_per_page?

    Thread Starter jglynnkcpbs

    (@jglynnkcpbs)

    Setting the page param to 1 still returns an empty array if the search param is used.
    https://website.com/wp-json/wp/v2/posts?page=1&post_per_page=5&search=videos

    Removing the search param from the URL expectedly returns the latest 5 posts on the site. In my testing, the post_per_page param was ignored and returned 10 posts by default.

    Plugin Author Ajay

    (@ajay)

    I need to do a bit more debugging on the rest api that I intend to do over the next couple of days. Clearly a bug but I need to figure out what’s causing it to happen, other than it being detected as a search.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.