jeudi 19 mars 2020

How do I format an 'else' in to this code?

I'm learning to code, and I know this is probably a terribly easy question to answer, but I just can't figure out how to echo nothing when there is no data here.

I know it has to do with using 'else', but where do I put it? This code basically summons social media links and I want both to be dependant on not showing if there is no data. I think there has to be somewhere in the first paragraph that the else code is supposed to go, but I really don't know where.

<?php if($instance['display_desc']) : ?>
<?php $description = get_the_author_meta( 'description', $user_id ); ?>
<?php echo wpautop( $this->trim_chars( $description, $instance['limit_chars'] ) ); ?>

<?php $instagram = get_the_author_meta('instagram'); ?>
<?php $twitter = get_the_author_meta('twitter'); ?>

<?php echo
$authsocial .= "<a class=\"author-ig\" href=\"https://instagram.com/" . $instagram . "\" target=\"_blank\" rel=\"nofollow\">@" . get_the_author_meta('instagram') . " </a>"
?>

<br />
<?php echo
"<a class=\"author-tw\" href=\"https://twitter.com/" . $twitter . "\" target=\"_blank\" rel=\"nofollow\">@" . get_the_author_meta('twitter') . " </a>";
?>

<?php endif; ?>

Aucun commentaire:

Enregistrer un commentaire