Support Forum
I 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 text
Do I make a group in the custom fields, make this group-field clonebale and the add three different subfields to the group?
Hi Cees,
Do you need to add more #1, #2, #3 items? If yes, you can create 3 cloneable fields textarea
or wysiwyg
.
If not, just create 3 fields textarea
or wysiwyg
. It is based on your requirements.
Hi,
Yes I need sometimes one, sometimes three etc. But each clonable row has three or four fields:
- taskname
- task-number
- tasktext
I is true that I have to use a group for this?
Hi,
I think creating a cloneable group is a good way. You can add more tasks with a set of tasks for each row.
It 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;
?>
Hi,
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
Hi Long,
Sorry.. it gives a Eval()'d code error and I can't figure out why.
Found!! Missing one } 🙂
Sorry.