Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It can be done. How depends on what format the resulting list is to be. If you requested mysite.com/allpost/?s=keyword a standard search would be run resulting an an archive listing of all posts with content or titles matching “keyword”. You don’t need to do anything to do this other than construct the correct URL parameters.

    Alternately, use the Rewrite API to cause WP to recognize your example’s “keyword” parameter and channel such requests to a custom template which could return results in any format you wish.

    Thread Starter omerosen

    (@omerosen)

    I am not sure that I understand you. My plan is to build a similar application to this.
    So every time a user will search something on my website he/she will get the posts that are matching the searched keyword. But I am missing an API in the form of http://api.mywebsite.com/allpost/keyword=xyz
    I hope this is more clear now.

    Moderator bcworkz

    (@bcworkz)

    I’m pretty sure I understand. I’m not sure what else to tell you to get my idea across. There’s no facility for this is WP out of the box. You need to create one. There’s two major parts. Getting WP to recognize your URL parameter and route such requests to the proper template. You use the Rewrite API to do this. This has nothing to do with your API other than enabling it.

    The other part is the template that actually sends the response to the request. This can be anything you want, I would suggest structuring the results as JSON would be a good approach. I fear this makes no more sense than my previous post, but I’m not sure what else to tell you.

    If you’re looking for a plugin solution and not a custom coded solution, I can’t help you, I’m not very knowledgeable about available plugins.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating an API’ is closed to new replies.