How can I search the post title and tag using WP_query of wordpress?

I am currently implement a search function to search the post from wordpress

I would like to search the post by Tag , by title and return it as JSON

Read More

I found a plugin that generate the result as JSON (JSON API)

http://wordpress.org/plugins/json-api/other_notes/#2.1.-Core-controller-methods

In that plugin , there is a get_posts function that can return the query that support WP_query parameter

I tried a query like that

http://MyWordpressSite.com/?json=get_posts&status=published&orderby=date&order=DESC&lang=en&s=eng&tag=eng&cat=9,10,14,15

where the &s= is the keyword to search while the &tag= is the tag to search

However, there are two problem

  1. How can I limit the search to title only?
    http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter

From the official website, it state search keyword ,but not limit to title only

  1. It seems the condition is tag “AND” keywords are match, but what I would like to achieve is tag “OR” keywords are match

http://codex.wordpress.org/Function_Reference/get_posts

So, to sum up , the goal is to search the post by Tag , by title and return it as JSON (actually is call the php through JSON), it doesnt matter using the plugin or not, any way achieve the goal is welcomed. Thanks for helping

Related posts

Leave a Reply