This might be useful too if you have multiple fields to check :
function hide_empty( $atts, $content = null ) {
$values = shortcode_atts( array(
‘field’ => ”,
), $atts );
echo do_shortcode( ‘[apr_populate field=”‘.$values[‘field’].'” relatedTo=”Exercices”]’ );
$nom_exercice = do_shortcode( ‘[apr field=”‘.$values[‘field’].’|Nom de l\’exercice”]’ );
if (empty($nom_exercice)) {
$content=”;
}
return $content;
}
add_shortcode(‘hide_empty’, ‘hide_empty’);
This creates an enclosing shortcode [hide_empty field=”YOUR FIELD”] YOUR CONTENT [/hide_empty]
If “YOUR FIELD” is empty, then “YOUR CONTENT” won’t be displayed.
Well it might not be the best way to do it, but once again it worked for me…