Current search facility in WordPress is very basic and simple. It doesn’t allow complex search facilities. Current search feature in WordPress only searches within post titles and content and does not search tags and categories (i.e. if there is a tag how to and a user searches for “how to” the set of posts tagged how to will not appear, rather it will search inside posts to match “how to”). Also, it is not possible to search within a certain tag, category or a time period; for instance, it is not possible to search for “news” in posts published last month.
Since search is a core functionality, it’s proposed that this advanced search feature be implemented in the core, so that other plugins and themes could easily use it. It also doesn’t support advanced boolean search query formats (grouping, OR, NOT, AND). For these reasons I have planned to extend the current search facility of WordPress.
The proposed query string for the search will be as follows, and this has been designed based on formats used by popular search engines such Google and Yahoo,
|Phrase Search (””)||“php programming”||Matches only the exact phrase php programming|
|AND, +||php AND programming||Matches text containing both php and programming. AND operator will be used by default.|
|OR, |||php OR c++||Matches text containing php or c++|
|NOT, –||php NOT c++||Matches text containing php and not c++|
|Brackets ()||(php OR c++) AND programming||Matches text containing php or c++ which also contain the word programming|
The following are the operators for advanced search,
|title:||title:wordpress||Matches posts which has the word wordpress on title|
|content:||content:summer of code||Matches posts containing words summer, of and code in its content.|
|tag:||tag:coding||Matches posts with tags containing word coding|
|category:||category:coding||Matches posts in categories containing word coding|
|anywhere:||anywhere:soc||Equivalent to title:soc content:soc tag:soc|
|time_from:||time_from:March||Matches posts published march, 2009 onwards. Note that the string would be intelligently identified. E.g. March could be sufficient instead of 03/01/2009|
|time_to:||time_to:2009||Matches posts published before 01/01/2009|
The above search syntax will enable users to directly search from the search box or to use an advanced search form where the user has to enter the details in a form, and a search query in the above format is automatically generated.