I want to build a view where I can filter whether or not a textfield on my post type contains text or not. For example, I have a projects post type. Besides other fields and taxonomies, the post type has a WYSIWYG field called "references" (the customer of the project can write a reference about the project). The reference field can also be empty.
In my search, I now want to be able to filter my projects by "With references", "Without references" and "With and without Referece".
It's not possible, because a field that has no content is not saved against the post, and hence, does not exist.
This is the same for any field type.
It's a feature that needs to be added to Toolset (ability to filter for exists or exists_not in metadata), and you'd have to submit this suggestion here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Currently, the best would be to create a Radio Field with 2 options (has and has no reference).
Then update all posts with the proper value and later create either a backend query or front end search in a View for that Radio field, which will let you choose either "has" or "has no" reference.
You can use a checkboxes search input to allow marking both, which then returns both results with "has" and "has not" value saved.
Please do not forget to submit the suggestion to our Product Manager to implement searches for not existing fields and update the current != comparison to make it smoother querying empty/not existing fields.
('compare' => 'NOT EXISTS', see https://codex.wordpress.org/Class_Reference/WP_Meta_Query)
I see. Are there hooks to implement a custom filter? For example if I would add a HTML input myself (select with those three options) and before Toolset creates the query, I would read the value from that input and manually add it to the query?