Advanced Search Options for WordPress

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,

Operator Example
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,

Operator Example
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.


About kishanthan

I’m currently working as a Software Engineer at WSO2, an open source software company. I hold an Engineering degree, majoring in Computer Science & Engineering field, from University of Moratuwa, Sri Lanka.
This entry was posted in WORDPRESS and tagged , , . Bookmark the permalink.

One Response to Advanced Search Options for WordPress

  1. Mr WordPress says:

    Hi, this is a comment.
    To delete a comment, just log in, and view the posts’ comments, there you will have the option to edit or delete them.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s