简体   繁体   中英

ACF Comma separated array values

I have a checkbox with several values.

I would like to display them separated by commas.

With my code, however, only one value is always displayed, although several are selected.

I think a loop is wrong here.

Even if I can get the values to be shown, they are not in the table, but rather in the "heading".


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM