Add this temporarily to your functions.php
. It will break things but you can see the WHERE
clause. Be sure to remove it because things won’t work right if you leave it there.
function dump_where($w){
var_dump($w);
}
add_filter('posts_where','dump_where');
The first thing you should notice is that the %
signs get escaped. Remove those and WordPress will add them back unescaped. If you only wanted one of those at the beginning or the end, but not both, this might be trickier. Luckily you don’t.
Second, the default relationship appears to be AND
so unless you want to enforce a match on every one of those meta_key
s you should add a relationship
to your meta query.
$query->set( 'meta_query', array(
'relation' => 'OR',
array(
'key' => '_st_plaintext',
/* and the rest of your query */
Third, post content is already searched.You shouldn’t have to do anything to make that happen. Take a look at the WHERE
clause my temporary code dumps and you should be able to see where that happens.