Andrea6999 Posted September 22, 2023 Share Posted September 22, 2023 I have to put a condition on this function: <div class="imagen01"> <?php sacconicase_post_thumbnail();?> <div class="mostrasconto"><?php echo (" "),"-", get_the_author_meta('discount', $post->post_author ),"%" ;?></div></div> I have to set the following: IF "get_the_author_meta" is empty, dont echo BUT dont show neither the whoole div.mostrasconto. I have to hide this div because there is a background via css Which is the best solution? Quote Link to comment https://forums.phpfreaks.com/topic/317311-setting-a-conditional-in-contentphp/ Share on other sites More sharing options...
Phi11W Posted September 22, 2023 Share Posted September 22, 2023 Not sure about best, but this should do the trick: <?php sacconicase_post_thumbnail(); $am = get_the_author_meta( 'discount', $post->post_author ); if ( $am ) printf( '<div class="mostrasconto"> -%s%%</div>', $am ); ?> Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/317311-setting-a-conditional-in-contentphp/#findComment-1612047 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.