The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
Complex fields such as checkboxes fields are stored as an array, and arrays are saved in the post_meta table as serialized strings (of the format you can see above).
This happens automatically when inserting data using update_post_meta, and is automatically reversed when extracting data using get_post_meta.
So if you use get_post_meta to get the value of the checkboxes custom field it will return an array, something like this:
Your meta query should be "=", but if you are going to be testing for multiple values (e.g. visibile and importante) then you will need to add multiple meta query terms with the relation 'AND' or 'OR' according to your needs.
The meta query you write will be different depending on whether you have one or two terms to match (e.g. just 'importante' or both 'visibile' and 'importante').
You can use count (hidden link) to determine whether you are dealing with a single field or two fields, and you will have to construct the meta_query differently depending on the result.
If one you can output the value required using $options_values[0][0], if two you can output them using $options_values[0][0] and $options_values[0][1], but the meta_query will look slightly different as I described at the end of my last response.
The Views plugin is designed to overcome such difficulties if you are unfamiliar with PHP and WordPress meta queries by doing this for you without the need to write any code.
Sorry, if you want to use Types to create custom queries then you need to have some basic PHP knowledge and know how to code such queries. We created Views precisely for users who want to build such queries without knowing how to code them.
The official documentation on meta queries is a little short on examples, but there is a nice example page here which demonstrates creating different kinds of meta queries which should be enough with the description above for you to be able to generate the meta query in the right format.
Sorry, I do understand the issue, but writing custom meta queries is outside of our support policy, which is why I have been directing you to documentation showing how to do so.
Good luck with it, I hope you get it working.
The forum ‘Types Community Support’ is closed to new topics and replies.