Search All Plugin

UPDATE (2010-01-25):

Some time ago, Dan Cameron, who wrote the original Search Everything on which I based this plugin, incorporated the additions I made to his original work, and I’ve neglected to point users over to his work. If you’re interested in the things that Search All did, please go support Dan’s work instead.

The Search All Plugin ([Get Dan’s plugin]) adds capability to search pages, attachments, draft posts, and comments to the WP default search, with an admin console to contol search options.

Installation is simple. Download the archive file and extract it. Copy the search_all.php file to your plugins directory. Enable the plugin and visit the options page to set the options.

Option Descriptions

  • Search Pages – search the content of pages for the searched for string
  • Search Comments – search for posts with comment containing the searched for string
    • Approved Comments Only – if checked will only check the contents of approved comments; otherwise will search all comments
  • Search Drafts – include posts with Draft status in the search
  • Search Attachments – include uploaded file’s title’s and descriptions for the searched for string.

Each checked option will be added to the default WordPress search function.

Change Log

This plugin is obsolete

See above, or go get Dan Cameron’s Search Everything

Version 0.3

  • removed requirement for searchform.php

Version 0.2

  • fixed comment search bug

Version 0.1

  • initial release


Thanks to Dan Cameron for Search Everything, and via Search Everything, thanks to to David B. Nagle for Search Pages and before that to Rob Schlรผter for this hack.
This plugin discards some of the options for exact and sentence searches included in Search Everything because there’s apparently no way for user easily to access these options (aside from typing into the URL). It also removes some of the query-string safety functions in Search Everything, because it seems to me that those are adequately handled in the wp-db class in WordPress.


Please leave a comment below.

  • Bob

    Thanks for adding the updates. It works great.

  • Mike Dent

    Sounds great. I cant help wondering if WordPress plugins which add extra functionality to the core of WordPress, such as this plugin, add any extra security holes to a wordpress site?
    It’s easy to add lots of plugins to several WordPress sites that one looks after but is adding more creating more work to keep them all up to date?
    Forgive me if I am way of mark here.

    thanks all the same, I shall be installing and testing soon to one of my sites!

  • cori

    Bob- Thanks, glad you like it. Your idea about styling the different sorts of searches is a good one and I hope to code it in soon.

    Mike – The way the searches work is to add some “where” clauses to the MySQL query that selects the list of posts to display. WordPress core code already deals fairly well with the risks involved with SQL injection vulnerabilities for database queries, so I don’t think this one adds a significant risk. Other plugins may (and some probably do) increase security vulnerability. And yes, having a lot of plugins can be kind of a hassle. It’d be nice if there was some sort of plugin auto-update feature builtin (or perhaps there is and I don’t know about it).

  • Bob

    I found an easy way to differentiate between pages and posts using the $post->post_status variable (which is ‘static’ for pages), but I’m not sure if there is a similarly easy thing that can be done to tell if it is a comment.

  • Dan

    Awesome work. I’ve just pushed the plugin aside too long, now you’ve made me get to work.

  • Mike Dent

    I have installed it and it works, nice. Thanks.
    What would be really nice is the ability to highlight the searched words in the displayed results.
    Guess this might not be easy though.

  • Justin

    Thanks for taking up the development of this plugin–I think it’s essential and am a little disappointed the functionality was not included in WP2.0.

    I installed the plugin on a test blog: It works well except that for some reason it won’t search comments regardless of the checkboxes in the admin area. Any ideas?

  • cori

    Thanks to Justin, who caught a bug and also tested it for me.

    The comments search didn’t work – the database query didn’t have any wildcard characters. Entertainingly enough, my main tests were done on a site with few comments, and I was searching for a word that was also the entire comment, so it worked there.

    Version 0.2 posted for download.

  • Jens

    Hi Dan!

    How about searching category-descriptions? Is this possible with a hack?


  • Rimmon

    It doesn’t work on Blix theme. It couldn’t find anything in comments even though I had checked it.

  • Darren


    I’ve uploaded this plugin – it’s great BUT, the search results are the complete post or page rather than a few lines of text like yours. Any ideas how I do this? I am using the most recent version of WP but a customised theme.

  • cori

    Can I get your url so I can take a look?

    I’m Cori, not Dan ๐Ÿ˜‰ No hack that I know of to search categories, but it’s probably possible.

    I don’t use Blix, but when I have a few moments I’ll take a look.

  • kiran


    i installed the plugin on my local machine. i tried searchind for a comment string from my website(local machine again) but it returns nothing.i am using wordpress 1.5. also when i goto the optins page, i only see the check boxes and no text box. how do i make this work on my site????

  • cori

    I don’t know what to say about the comment search functionality; it works fine on the several sites and themes I’ve since tested it on. Can you tell me what theme you’re using? I’d like to install it and Blix and see what I can figure out.

    As far as the missing text box, that was a feature I hadn’t tested on any theme aside from my own mod of the WP-Default theme which has been the only theme at elliptical… since I opened the site. That oversight meant that I assumed that something was part of the default wp install that wasn’t; I’ve fixed this in version 0.3 that’s available to download now (this is the only change in 0.3).

    Please give it a try and let me know how it goes…..

  • mark


    I’m new to WordPress, just installed 2.0 and your plug-in…but can’t get it working…

    I activated it and set all the options, but still don’t see any results for text strings that I put into the few posts that I’ve made tonight.

    Please help? This is going to be a church site for some friends of ours (test URL is here:

    Many thanks ~

  • mark

    *update* … I’m now getting results for posts that are “uncategorized” only, but not if they have other categories assigned (such as “events” or “staff”).

    I tried making “staff” a child category of “uncategorized” to see if that would work, but still no results for anything other than posts that are “uncategorized”.

  • cori

    Hi Mark;

    Can you post a link a snapshot of the options page? Trying it out on your site and I can certainly get returns on pages, but don’t see posts returned.

  • mark

    Hi Cori,

    Here’s a screen shot of the Search All options page:

    I’ve selected almost every option; could that cause a conflict? Are future events (my posts with a future date) even searchable?

    Thanks again,


  • cori

    OK, Mark, now we’re getting somewhere.

    Looking at the last post in your upcoming events category I see that you have some posts set for future dates. I suspect that whatever’s keeping them off the blog’s front page may be interfering with the search feature as well.

    I don’t pay any attention to the date of the post, but I only select posts where the status is “published”, “static”, “draft”, or “attachment”, depending on your settings. I wonder what the statuses of the posts in your upcoming events category are? I also note that I can see the posts in the category archive but not on the front page and when I try to get the single-post view of the post I get a 404 error. Why is that, do you think?

    In my tests, selecting every option works just fine.

  • mark

    Since I only have two plugins added to the Default theme, I thought that the EventCalendar plugin might be the problem…so I changed its option from “Keep events separate” to “Events are normal posts”. I assumed this would fix it, but no joy.

    I must have tripped up when I first set up the WP 2.0 install ~ I’m going to wipe the whole directory and start fresh, only installing your plugin. Perhaps then we’ll be able to isolate the trouble.

    I appreciate your help, and the time it must take to write a plugin.


  • ovidiu

    any chance to get this plugin to search for tags too? would be great.

  • cori


    I’ve thought about that, but I think it’d be fairly difficult because there are so many way to attach tags, essentially all of which are plugins vs WP core code. So each one would be likely to have a different mechanism for storing the tags and each would its own way of searching for them.

    For example, how do you tag your posts?

  • ovidiu

    now that you say so I can see the truth of your words,…

    I use UTW ultimate tag warrior for tagging…

    the reason I am asking for this feature is that I use a tag cloud and would like to combine it with the search function which actually works except for the fact that searching for tags does not.

  • Amit

    Hey Cori,

    I’ve just installed wordpress 2.0 on my website/blog and was wondering if it was possible to be able to put the search field on all pages. I’m not referring to searching all pages, which I want, but actually putting a search textbox on all my pages so someone can search whether they are on the blog portion of my site or not. My “index” page or first page, is not my blog. You can take a look at my site and click on “Toggle Search” and you’ll understand where exactly I’d like to put the search feature. I’m guessing using an absolute path to the search function of wordpress would do the trick?

  • cori

    Hi Amit;

    I don’t think an absolute-path include of the search page will be sufficient in this case – you’d be missing a lot of the object includes that are prerequisites to the actual search features.

    In order to use the WordPress search outside the WP architecture you’ll need to make sure you have handles on the critical objects for the search to work. That’s at least the stuff in wp-db.php, because search uses the gloal $wp-db object, but probably a few other things as well; I don’t know off-hand. Search (and Search-All.php) uses a few hooks that aren’t in wp-db.php.

    Your best bet would be to look at the hooks and filters I’m using and to search one of the source repositories to find out where those hooks and filters are defined. There’s a good cross-reference of the latest trunk of code at Since it’s trunk it doesn’t match what I’m running precisely, but it’s close enough for exploration.

  • _ck_

    Is it a bug or limitation that for the search results loop, is_page() is NOT set when it finds a page?

    I guess you are just extending the mysql query but there’s no way to filter the results?

    I guess I can test for a date before 2000 which would make it a page vs a post (if I can figure out the code in less than an hour ๐Ÿ˜‰

    Apologies for this next question as I bet it’s been asked before but darn if I can find the answer.

    How can I (easily) give the visitor the option of searching comments (or not) via a checkbox added to the search form? Is there a way to hook into your routine to toggle that specific area on and off? I don’t suppose a form field of “comments_approved” with a value of 1 (or 0 ) would work, too easy?

  • cori

    Um, neither? I suppose it could be thought of as a limitation – I just never considered it very important to delineate between pages and posts. You can test for it in wp_posts, post_status = Static, which means it’s a page. I’m not sure what you’re looking for for the is_page() functionality in the results – can you be a little more specific?

    As far as searching for comments is concerned there’s not much you can do at the search form stage – those options are currently only handled in the admin page, and the search filters check the database for their status when filtering the results. I’d have to add in the ability to check for post variables in addition to database values in order to account for that.

  • _ck_

    The problem with is_page() not being set for a “page” search result is that the date will attempt to be shown for what wordpress thinks is a “post”.

    So people end up seeing a search result with a date of 1969 for a “page”. It’s ugly.

    I guess I can modify my template to directly check post_status for static but that kind of defeats the purpose of is_page() ๐Ÿ˜‰

    Not sure about others, but I’d definitely like to give the website visitor the option of excluding or including comments so they can limit their search results if they get too many. We had that option with movabletype and I miss it in WP. We also had the option of using regex/logic in the searchbox (ie. ANDing NOTs and ORing the search terms) but I guess that is a WP feature that is far off in the future.

    On another feature thought, I pondered for awhile about how to make WP highlight the search terms in the results but because it uses a function call that also serves as a hook, I guess I can’t replace it in my template. Perhaps as a new plugin feature idea to pre-filters the results. I don’t suppose you are up for adding such an ability? I guess it would be best as a separate plugin and not put into SearchAll.

    ps. do you know if SearchAll is 2.1 compatible? I don’t see it on this list yet
    and I was considering giving it a shot this weekend

  • Liss

    Plugin is not compatible with Ocadia Theme.. cannot seem to get it to work with Pages Or Comments.


  • rbs

    only a question

    function SEv_log($msg)
    what it does?

    is this that memorize the status of options selected?

  • hh

    hey cori. i created a custom theme — is there something special that i need to include in my search template??? i can’t get it to search anything but posts — no pages, comments, etc.

    thanks in advance.

  • _ck_

    Hi, nice work on this.

    I believe I found a bug in 0.3 where even if “search draft” is UNchecked, if a term appears in a comment on a draft, it will still return the result. That is definitely undesired behavior.

    I’m looking through the code for a fix now but just wanted to let you know about this asap.

  • manuel

    Hi, thanks it is a great plugin.
    I would like to ask you if will be any way to use it with wordpress mu (multy user). I’m looking for a pluging or hack to have the possibily to make search across a blog comunity using tags too. Any clues will be wellcome, Thanks. Can I use all search for this?
    Thanks again for your work

  • shawn blanc

    I’ve been using the Search All plugin for a while and like it a lot, but It’s not working with WP 2.1

    When searching for a term it brings up multiple results of the same posts.

    I’m looking forward to an updated one.

  • Guy Rintoul

    Hi there,

    I *love* this plugin – does just what I wanted :-) One thing though – I’d like to be able to tell if a result is a page or something else (i.e. post or comment)… I don’t really understand the whole debate about about checking is it’s “static” as I’m not much of a coder… Would anyone be able to just tell me, if I have the following code what expression do I use instead of CONDITION to check whether it’s a page? If it’s a page CONDITION should be true (i.e. “format the result one way”) otherwise it’ll be false (i.e. “format the result another”).

    // format the result one way

    // format the result another

    Thanks so much in advance for your help and the AMAZING PLUGIN :-)


  • Guy Rintoul

    Hmm, my code didn’t show up, must have been stripped during posting… it was basically a PHP statement that said:

    // format the result one way
    } Else {
    // format the result another

    So it’s just a PHP expression I need for CONDITION


  • edetotal

    Howdy Cory& the others,
    thanks for this neat piece of code.
    Is there any way to customize this plugin in a way that I could search other tables, like some made by other plugins?

  • Steve C

    Perhaps you can help, either I did something wrong or your great plugin is simply not compatible with the template I’m using: Green – Elegancy 2.3 by Viajes

    The search box does not show up on the page, not even in the Search all options page although there I do see the various checkboxes to allow me to search different things like pages, attachments, comments etc. The plugin has been activated but will not display, any ideas?

    Steve C.

  • Steve C

    Oh, one thing I forgot to add if it makes a difference, I’m on Mac using Firefox
    Steve C.

  • Al

    Can’t get it working. Dan’s plugin worked fine untill a couple of weeks ago, I didn’t even upgrade or something, just running 2.1. Now I tried yours, I only need search pages besides blog but it does not work. I tested it in Modern Theme plus in the latest K2 nighty built. Hopefully WP will include this very important function, working…

  • Ian


    Great plugin, but cant get it to work for me! has a search field at the top but still only searches posts. I have selected pages and attachments, but not showing. Any thoughts?



  • Pingback: Make WordPress search better | Chilly Cool Blogger Resources

  • Pingback: Northern-Web-Coders