Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic MetaBox doesn't saves and it doesn't work with selected category Reply To: MetaBox doesn't saves and it doesn't work with selected category

#9380

Anh Tran
Keymaster

This code:

$birra = isset( $passaggio['et2018-nome_birra'] ) ? $passaggio['et2018-nome_birra'] : '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';

is wrong and can’t work.

This code:

if (isset($passaggio['et2018-nome_birra'])){
                    $birra = $passaggio['et2018-nome_birra'];
                }
echo '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';

works. But it will show a warning if there is no value for $passaggio['et2018-nome_birra']. And in case there’s no value, it still show the <a> link.

Please try this instead:

$birra = isset($passaggio['et2018-nome_birra']) ? $passaggio['et2018-nome_birra'] : '';
if ($birra) {
    echo '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';
}