Group or not?
- This topic has 7 replies, 2 voices, and was last updated 4 years, 2 months ago by
[email protected].
-
AuthorPosts
-
October 2, 2021 at 4:28 PM #31111
[email protected]
ParticipantI make a portfolio website with all my projects. With Custom Fields I fill all my project fields. I will make a group with tasks in a project
#1 : website development : a lot of text
#2 : photography : a lot of text
#3 : SEO : a lot of textDo I make a group in the custom fields, make this group-field clonebale and the add three different subfields to the group?
October 2, 2021 at 5:36 PM #31112Long Nguyen
ModeratorHi Cees,
Do you need to add more #1, #2, #3 items? If yes, you can create 3 cloneable fields
textareaorwysiwyg.If not, just create 3 fields
textareaorwysiwyg. It is based on your requirements.October 2, 2021 at 6:26 PM #31113[email protected]
ParticipantHi,
Yes I need sometimes one, sometimes three etc. But each clonable row has three or four fields:
- taskname
- task-number
- tasktextI is true that I have to use a group for this?
October 3, 2021 at 8:43 AM #31118Long Nguyen
ModeratorHi,
I think creating a cloneable group is a good way. You can add more tasks with a set of tasks for each row.
October 3, 2021 at 2:14 PM #31121[email protected]
ParticipantIt won't display at the front-end. What is wrong? I have a group_id pj_taken and two subfields pj_taak and pj_taak_text. I also don't understand the ??'' in the code sample from your website.
$group = rwmb_meta( 'pj_taken' ); if ( empty( $group ) ) { } $output = ''; // Sub-field title. $title = $group['pj_taak'] ?? ''; $output .= '<h3 class="my-title">' . $title . '</h3>'; // Sub-field description. $desc = $group['pj_taak_text'] ?? ''; $output .= '<div class="my-description">' . wpautop( $desc ). '</div>'; echo $output;?>
October 3, 2021 at 8:15 PM #31123Long Nguyen
ModeratorHi,
If it's the cloneable group, you need to use a loop to iterate through group elements. For example:
$group_values = rwmb_meta( 'pj_taken' ); if ( ! empty( $group_values ) ) { foreach ( $group_values as $group_value ) { $value = isset( $group_value['pj_taak'] ) ? $group_value['pj_taak'] : ''; echo $value; // Display sub-field value } }Get more details on the documentation https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-values
October 3, 2021 at 9:29 PM #31124[email protected]
ParticipantHi Long,
Sorry.. it gives a Eval()'d code error and I can't figure out why.
October 3, 2021 at 9:30 PM #31125[email protected]
ParticipantFound!! Missing one } 🙂
Sorry.
-
AuthorPosts
- You must be logged in to reply to this topic.