[英]ACF Comma separated array values
我有一个包含多个值的复选框。
我想用逗号分隔显示它们。
然而,在我的代码中,虽然选择了多个值,但始终只显示一个值。
我认为这里的循环是错误的。
即使我可以得到要显示的值,它们也不在表格中,而是在“标题”中。
<?php
$args = array(
'post_type' => '3d_drucker',
'posts_per_page' => '100',
'orderby' => 'Title',
'order' => 'ASC',
);
$Vergleichstabelle = new WP_Query($args);
if($Vergleichstabelle->have_posts()) {
?>
<table class="wp-list-table widefat fixed striped posts sortable">
<thead>
<tr>
<th scope="col" id="title" class="manage-column column-title column-primary sortable desc" style="cursor: pointer; width: 230px;">Bezeichnung</th>
<th scope="col" id="5df4849c8e9c9" class="manage-column column-5df4849c8e9c9 sortable desc" style="cursor: pointer">Hersteller</th>
<th scope="coL" id="5df4ffb88b01d" class="manage-column column-5df4ffb88b01d sortable desc" style="cursor: pointer">Typ</th>
<th scope="col" id="5df4849c8df18" class="manage-column column-5df4849c8df18" style="cursor: pointer; width: 250px;">Filament</th>
<th scope="col" id="5df85bd34be85" class="manage-column column-5df85bd34be85 sortable desc" style="cursor: pointer">Verfahren</th>
<th>Infos zum Gerät</th>
</tr>
</thead>
<tbody>
<?php
while ($Vergleichstabelle->have_posts()) {
$Vergleichstabelle->the_post();
// Wenn mindestens 1 Datensatz vorhanden ist
// Platzierung aus Feld laden
$bezeichnung = get_field( 'bezeichnung' );
// 3D Drucker aus Feld laden
$hersteller = get_field( 'hersteller' );
// Listenpreis aus Feld laden
$typ = get_field( 'typ' );
// Aktionspreis aus Feld laden
// $filament = get_field( 'filament' );
$filamente = get_field('filament');
if($filamente)
{
foreach($filamente as $filament)
{
}
}
// Gutschein aus Feld laden
$verfahrens = get_field( '3ddruck-verfahren' );
if($verfahrens)
{
foreach($verfahrens as $verfahren)
{
}
}
// Info aus Feld laden
$info = get_field( 'info' );
echo "<tr>";
echo "<td>$bezeichnung</td>";
echo "<td>$hersteller</td>";
echo "<td>$typ </td>";
echo "<td>$filament </td>";
echo "<td>$verfahren</td>";
echo "<td>$info</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<?php
} // end if have posts```
我仍然没有进一步......我找到了以下代码,但它只显示“数组”......真的很愚蠢
$filamente = get_field( 'filament' ); foreach($filamente as $filament): $filament_fields = get_field('$filament', $filament); if( $filamente_fields ): $filament_fields_slugs = array_column($filament_fields, 'slug'); $data_filament_slugs = implode(', ', $filament_fields_slugs); endif; endforeach;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.