I’m having trouble matching a data that is a serialized array.
I had assumed that the following code would work but it doesn’t. I only want to return records for which the key is defined and the serialized data contains the key value pair where the value is true.
The problem is that WP escapes the % sign in the ‘value’ => ‘%isfanpage%true%’ clause and adds its own % signs, so what is sent to MySQL is this:
I think one way to solve this would be to use ‘value’ => ‘isfanpage%true’ and then use a filter to replace ‘\\%’ with ‘%’ in the query.
This still may produce unexpected results if the word true occurs anywhere after the word isfanpage, not just as its value. It might be better to use the proper number of underscores between the two words and replace ‘\\_’ with ‘_’.