MB Group field listing
- This topic has 3 replies, 2 voices, and was last updated 1 year, 1 month ago by
Peter.
-
AuthorPosts
-
March 17, 2024 at 4:15 AM #44884
Jayron Castro
ParticipantI 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.
March 18, 2024 at 9:01 PM #44895Peter
ModeratorHello 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
March 18, 2024 at 11:01 PM #44901Jayron Castro
ParticipantI 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?
March 19, 2024 at 6:57 PM #44911Peter
ModeratorHello,
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
. -
AuthorPosts
- You must be logged in to reply to this topic.