Post title instead of ID
- This topic has 2 replies, 2 voices, and was last updated 3 years, 7 months ago by
toni bird.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
September 20, 2021 at 8:55 PM #30850
toni bird
ParticipantHi guys , Was wondering if its possible to save the post title into my group array , not the ID as shown bold below:
a:2:{i:0;a:3:{s:7:"staff_d";s:4:"7151";s:11:"staff_d_qtd";s:1:"1";s:10:"sd_factorx";s:1:"9";}i:1;a:3:{s:7:"staff_d";s:4:"7153";s:11:"staff_d_qtd";s:1:"1";s:10:"sd_factorx";s:1:"9";}}
My group code below
[ 'id' => $prefix . 'rev_staff', 'type' => 'text', 'name' => "###ATEN\xc3\x87\xc3\x83O - Itens listados aqui devem ser revisados.###", 'size' => 160, 'columns' => 12, 'tab' => 'staff_tab', ], [ 'id' => $prefix . 'group_staff_d', 'type' => 'group', 'name' => esc_html__( 'DIRETO', 'text-domain' ), 'fields' => [ [ 'id' => $prefix . 'staff_d', 'type' => 'post', 'name' => "###Fun\xc3\xa7\xc3\xa3o###", 'post_type' => ['efetivo'], 'field_type' => 'select_advanced', 'columns' => 4, ], [ 'id' => $prefix . 'staff_d_qtd', 'name' => esc_html__( 'Quantidade', 'text-domain' ), 'type' => 'select', 'options' => [ '' => esc_html__( '', 'text-domain' ), 1 => esc_html__( '1', 'text-domain' ), 2 => esc_html__( '2', 'text-domain' ), 3 => esc_html__( '3', 'text-domain' ), 4 => esc_html__( '4', 'text-domain' ), 5 => esc_html__( '5', 'text-domain' ), 6 => esc_html__( '6', 'text-domain' ), 7 => esc_html__( '7', 'text-domain' ), 8 => esc_html__( '8', 'text-domain' ), 9 => esc_html__( '9', 'text-domain' ), 10 => esc_html__( '10', 'text-domain' ), 11 => esc_html__( '11', 'text-domain' ), 12 => esc_html__( '12', 'text-domain' ), 13 => esc_html__( '13', 'text-domain' ), 14 => esc_html__( '14', 'text-domain' ), 15 => esc_html__( '15', 'text-domain' ), ], 'columns' => 3, 'visible' => [ 'when' => [['staff_d', '!=', '']], 'relation' => 'and', ], ], [ 'id' => $prefix . 'sd_factorx', 'name' => esc_html__( 'HHT', 'text-domain' ), 'type' => 'select', 'std' => 9, 'options' => [ '' => esc_html__( '', 'text-domain' ), 1 => esc_html__( '1', 'text-domain' ), 2 => esc_html__( '2', 'text-domain' ), 3 => esc_html__( '3', 'text-domain' ), 4 => esc_html__( '4', 'text-domain' ), 5 => esc_html__( '5', 'text-domain' ), 6 => esc_html__( '6', 'text-domain' ), 7 => esc_html__( '7', 'text-domain' ), 8 => esc_html__( '8', 'text-domain' ), 9 => esc_html__( '9', 'text-domain' ), 10 => esc_html__( '10', 'text-domain' ), 11 => esc_html__( '11', 'text-domain' ), 12 => esc_html__( '12', 'text-domain' ), 13 => esc_html__( '13', 'text-domain' ), 14 => esc_html__( '14', 'text-domain' ), 15 => esc_html__( '15', 'text-domain' ), ], 'columns' => 3, 'required' => 1, 'clone_default' => true, 'visible' => [ 'when' => [['staff_d_qtd', '!=', '']], 'relation' => 'and', ], ], ], 'clone' => 1, 'default_state' => 'expanded', 'group_title' => '{staff_d} : {staff_d_qtd}', 'clone_default' => true, 'tab' => 'staff_tab', ],
My problems is, that in views when I use :
<?php foreach ($staff_d_array as $row): array_map('htmlentities', $row); ?> <tr style="border-bottom: 1px solid #ddd; word-break:normal"> <td ><?php echo implode('</td><td>', $row); ?></td>
is showing the ID not post title , many thanks
September 20, 2021 at 10:10 PM #30855Long Nguyen
ModeratorHi,
The field type
post
saves post ID(s) in the database. Please read more here https://docs.metabox.io/fields/post/#dataYou can use the WordPress function to get post title by ID as well https://developer.wordpress.org/reference/functions/get_the_title/
September 28, 2021 at 9:47 AM #31026toni bird
ParticipantHi Long, got it sorted, many thanks
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.