Support

Account

Home Forums Front-end Issues Display list of fields in front end – technical data table

Helping

Display list of fields in front end – technical data table

  • Hi, apologies in advance for my ignorance, I am currently learning PHP.

    I am trying to display my fields in the front end as table to create a technical data area.

    I have used some code that worked but because I had some checkboxes it would return ‘array’ in the front end. This is the code I used:

    function woo_new_product_tab_content()  {
    	
    $fields = acf_get_fields('10631');
    
    if( $fields )
    {
      foreach( $fields as $field )
      {
        $value = get_field( $field['name'] );
        if ($field['choices']){
        
        
    
        }
        if( $value && $value != 'no') {
          echo '<table style="margin-bottom:0.5em;"><th style="width:50%;background-color: #ebebeb;">' . $field['label']  . '</th><td style="width:50%">' . $value . '</td></table>';
      }
    	  
    }
    	
    }
     }

    I then created an extra bit of code to try and facilitate the checkbox fields, however once I add another get_field the data seems to repeat itself:

    $values = get_field('gate_usage');
    if ( $values) 
    {
      echo '<table style="margin-bottom:0.5em;"><th style="width:50%;background-color: #ebebeb;">Gate Usage</th><td style="width:50%">';
    	foreach ( $values as $value) 
    	{
        echo $v . '</td></table>';
      }
    }

    Can someone please help me?

    Many thanks.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.