Hi,
I have a post type, with a hundred of posts.
I want to add a checkbox, "featured" so that I can order them in a view : featured first and then by creation date.
If I introduce a new custom field, checkbox type and attribute the group to my old post type, I have to set manully which posts are featured, which is normal. But if I do not re-save old non-featured post, they are not showed in the list which is a bit inconvenient.
Hence my question : How to create a new checkbox custom field and give it a default value so that old post appear in queries sorted by that field, w/o reserving them all ?
Thanks !
Hi, there's not a straightforward way to do this within Toolset. You can set a default value in some custom field, but without resaving a post where that field exists, the default value will not be applied to that post automatically. There are a few options to consider:
1. A custom database script that inserts the default values everywhere necessary
2. A 3rd-party plugin that allows you to bulk-edit custom field values from the dashboard in wp-admin. I can't vouch for the effectiveness of any of these plugins unfortunately, as they are not created by Toolset, but some claim to expose custom fields in the bulk-edit interface. That could help speed up your editing.
3. Use custom code to modify the query programmatically to test whether or not a value exists using the comparison operator EXISTS. We offer the wpv_filter_query API for this purpose: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Let me know if you have questions about those options.
Thanks Christian,
I will go the SQL update way.
Could you point me where the custom fields are stored in WP ?
Thanks.
F.
Types fields are all stored in the postmeta table. In the database, you will see that the fields all have a 'wpcf-' prefix. So if the field slug in wp-admin is "color" then it will be "wpcf-color" in the postmeta table.
My issue is resolved now. Thank you!