I'm pretty green to WordPress (and with the work I've been doing in it, my reasons for avoiding it seem to have been justified), and one of the problems I'm having is that the post search is always exact.

I have a filter on posts_clauses and the WHERE clause that results from it seems to support an inexact search, but the results are always exact. I notice that it's an incomplete condition, and I don't know what the first half of it is. If I try executing the resultant query by hand using a vague condition like ID > 0, the expected posts show up.

What is the rest of the condition which shows up before $clause['WHERE']? What else could be causing it to always assume I want an exact search?


I've disabled the filter and have the following plugins active:

  • Advanced Custom Fields
  • Advanced Custom Fields: Date and Time Picker
  • Advanced Custom Fields: Options Page
  • Advanced Custom Fields: Repeater Field
  • Formidable
  • Google Analytics by Yoast
  • Regenerate Thumbnails
  • WordPress Importer

The field that needs to be searched is wp_posts.post_content and I've tried passing exact=0 to the search parameters.

  • 1
    Have you disabled all plugins? If so, have you tried using the one of the default themes? Commented Jun 24, 2015 at 22:49
  • I'm not sure exactly what you're trying to achieve but there are several plugins available (such as Relevanssi) that will do a fuzzy search. Maybe taking a look into how these plugins work may help you? Commented Jun 24, 2015 at 23:31
  • Post your code please? It is impossible to address vague "I did this then i did that so what's wrong?" questions.
    – s_ha_dum
    Commented Jun 24, 2015 at 23:47
  • 1
    I have a filter... Without seeing this exact filter, it is impossible to tell you what is wrong with your filter. Please post your filter so someone can take a look at it and help you Commented Jun 25, 2015 at 6:26
  • I don't suspect the filter is affecting it, as the search is still exact when it's not set. I'll try disabling plugins to see what's what, but it will probably break the site as it's a custom job. Please see the questions at the end. Commented Jun 26, 2015 at 13:03

1 Answer 1


Someone put search logic into a somewhat obfuscated theme file that was connected through a series of ludicrous includes.

  • 4
    I just can't resist to tell you that the downvotes were probably caused by the fact that you didn't make clear what your exact issue is. Talking about a filter without showing the code makes it impossible to help. Also on a sidenote: Starting off a request for help to a WordPress crowd by telling them implicitly that you think the system they are working with is bad isn't really encouraging for potential helpers, don't you think?
    – kraftner
    Commented Jul 1, 2015 at 15:35
  • Of course you can't. It's an unpopular question which people refused to answer either because they misinterpreted the question or because, as you put it, I implicitly stated I think WordPress is bad (rigid yet messy structure, and an awful mix of procedural and OOP). So why not chip in? I made clear what the exact issue was: all the searches were being treated as exact. I didn't post irrelevant code (in part because it had a lot of identifying information) and I explicitly requested a way to trace the exact query being used, a part of the question which seemed to be ignored entirely. Commented Jul 1, 2015 at 16:37
  • 3
    @DissidentRage Let's make it clear: WordPress code sucks. That said, your question was unpopular because simply not answerable. As a proof, the problem was somewhere that was not completely mentioned in the question. Your question was something like "I have a car. I did something on the engine. Now it doesn't power on. What can cause the problem? - Update: my car has blue upholstery, an MP3 reader and Xenon lights." Now, a question like that, no matter if the car is a Ferrari or a damaged lemon, can't be answered. By anyone, not even by the best car mechanic in the world.
    – gmazzap
    Commented Jul 1, 2015 at 18:52
  • So strange that someone refuses to post the relevant filter's code after being asked twice, and then still blames the community for not helping him to solve the issue. No wonder this question has recieved so much negative feedback Commented Jul 19, 2015 at 5:13
  • @gmazzap - Good job on the argumentum ad absurdum. That wasn't at all what happened, though I can see how easy it is to make that mistake. The problem was nobody followed specifically what I requested, and then complained that I didn't go through a rather lengthy (and irrelevant) filter and remove identifying pieces of code. My request was more like asking how to check the charge of a battery (not what was actually wrong with it) when it turned out to be a problem with the connection at the other end of the cable. The fact that I disabled the filter and it was still wrong didn't tip you off? Commented Jul 21, 2015 at 17:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.