Support Forum
I created a custom field called "Classes", within the field group I created a clonable subgroup with three fields, (Description, Active, Teacher), respectively.
I'm using Bricks Builder and when I need to list the fields, I just select the "MB Group Classes" post in the Query Builder and all records are displayed normally, even everything occurs normally and as expected.
My question is how do I list in this loop only the group records that have the "Active" field equal to true?
<div>
$groups = rwmb_meta( 'cg_class', [ 'object_type' => 'setting' ], 'customizacao-do-sistema' );
foreach ( $groups as $group ) {
// Field cf_description:
echo $group[ 'cf_description' ] ?? '';
// Field cf_active:
$checkbox = $group[ 'cf_active' ] ?? 0;
if ( $checkbox ) {
echo 'Checked';
} else {
echo 'Unchecked';
}
// Field cf_teacher:
echo $group[ 'cf_teacher' ] ?? '';
}
</div>
Only records with the active field = true can be displayed in the search loop.
Hello Jayron,
In order to correct your code, I need to check the field settings in the field group. Please export the field group to a JSON file and share it here, following the documentation https://docs.metabox.io/extensions/meta-box-builder/#export--import
I managed to solve the problem using a filter from the bricks builder theme, as I processed the query return before reaching the front-end, but I need to know if there is any way to solve the problem only through the metabox, as the objective is to list only the classes active.
Below is the code:
I would like to take this opportunity to ask where the metabox saves the data for the custom fields, because the wp_postmeta table only contains the definition of the fields, but I couldn't find the data in that table.
The image below shows the definition of the field that is saved in the wp_postmeta table, but I couldn't find the field data, can you clarify this question?
Hello,
According to this code https://pastebin.com/ZDcDxd0S I see the custom fields are associated with a settings page, so the field value will be saved to the table wp_options
. Please follow the documentation
https://docs.metabox.io/extensions/mb-settings-page/
Regarding the "meta_box" key in the table wp_postmeta, it's the data of the field group post, post type meta-box
.