ACF逗号分隔的数组值

问题描述 投票:1回答:1

我有一个带有多个值的复选框。

我想用逗号分隔它们。

但是,使用我的代码,尽管选择了多个值,但始终只显示一个值。

我认为这里的循环是错误的。

即使我可以显示这些值,它们也不在表中,而是在“标题”中。


<?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```
php wordpress while-loop echo advanced-custom-fields
1个回答
0
投票

我仍然走不远。我发现了以下代码,但是它只显示“ array”...。真的很愚蠢

$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;

© www.soinside.com 2019 - 2024. All rights reserved.