• I am trying to to search for post title from WordPress REST API V2. As I have checked the ‘search’ parameter will search both the post title and content but I need to only search for the title.

    I have asked in Chat GPT and it suggests to use ‘title’ parameter like wp-json/wp/v2/posts?title=Hello but it does not work. My wordpress version is 5.8.6. I am not sure can I use title parameter? or anything should I check for?

    Below is the answer from Chat GPT:

    There could be a few reasons why the title parameter is not working for you when using the WordPress REST API. Here are a few things you can check:

    1. Make sure that you are using the correct endpoint for your API request. The title parameter is only supported by the /wp-json/wp/v2/posts and /wp-json/wp/v2/pages endpoints, so if you are using a different endpoint, the title parameter will not work.
    2. Make sure that you are using the correct syntax for the title parameter. The title parameter should be followed by the title you want to search for, like this: title=Hello World.
    3. Check if there are any errors in your API request. If there are syntax errors or other issues with your request, it may not work as expected. You can use a tool like Postman or a browser extension like JSON Formatter to help you debug your API requests.
    4. Check if the title parameter is supported by your WordPress version. The title parameter was introduced in WordPress version 4.7, so if you are using an older version of WordPress, the title parameter may not be available.

    If you have checked all of these things and the title parameter is still not working for you, it’s possible that there may be a problem with your WordPress installation or server configuration. In this case, it may be helpful to check your server logs or consult with a WordPress developer for further assistance.

    • This topic was modified 3 years, 5 months ago by petch1994.
Viewing 2 replies - 1 through 2 (of 2 total)
  • In WP version 5.8.6 as well, I bielive you can use the search parameter as suggested my Chat GPT. Is there any specififc errors being noticed by you?

    Thread Starter petch1994

    (@petch1994)

    @rajinsharwar Thank for your prompt reply.

    Yes, I can use search parameter but it also search for the post content. I need to search for only the title with my query value. Chat GPT suggests me to use title parameter but it does not work.

    When I try to get wp-json/wp/v2/posts?title=hello, it returns the posts without hello keyword in the title. As I inspected in the network, there is no specific error occurred.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress REST API Title Search’ is closed to new replies.