0

I am try to hide the metabox fields with empty value like

$Product_Brennwert = get_post_meta(get_the_ID(), 'Product_Brennwert', true);
if ( ! empty ( $Product_Brennwert ) ) {
    echo 'Brennwert
'. $Product_power . '

';
}

now i am try to add this in my php file but no idea how to add this in table can some on help me to do this?

part of my php file Single.PHP

0

In your php file, replace:

<tr >
<td>Brennwert</td >
<td >'. $Product_Brennwert . '</td>
</tr >

with:

';
$Product_Brennwert = get_post_meta(get_the_ID(), "Product_Brennwert", true);
if(!empty($Product_Brennwert)){
    $grid_details .= "
        <tr>
        <td>Brennwert</td >
        <td>".$Product_Brennwert."</td>
        </tr>
    ";
}
$grid_details .= '
  • thx for the help its working after some modification... – John Kater Mar 4 '16 at 1:34
  • Please edit my answer to add your modification, then accept the answer. – Johano Fierra Mar 6 '16 at 5:26
0

thx for the help its working after some modification... one more question i have tablle to show the info but the title show alle time if i have ther any fiels or not. how can i hide this?? the title have to show only if one of the fields have value ... This part

$grid_details .= "<h2>Nährwerte &amp; Allergene</h2>
    <table class="ewtable">
<tbody>
<tr>
                        <td width="70%">
                            Nährwerte
                        </td>
                        <td width="20%">
                            pro 100g
                        </td>
                    </tr>';
$P_Energie = get_post_meta(get_the_ID(), "P_Energie", true);
if(!empty($P_Energie)){
    $grid_details .= "
        <tr>
        <td>Energie</td >
        <td>".$P_Energie."</td>
        </tr>
    ";
}
$P_Fett = get_post_meta(get_the_ID(), 'P_Fett', true);
if(!empty($P_Fett)){
    $grid_details .= "
<tr>
<td>Fett</td>
<td>". $P_Fett . "</td>
</tr>";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.