Я учусь кодировать, и я знаю, что это, вероятно, очень простой вопрос, но я просто не могу понять, как выводить эхо, когда здесь нет данных.
Я знаю это связано с использованием 'else', но куда мне его поместить? Этот код в основном вызывает ссылки на социальные сети, и я хочу, чтобы оба зависели от того, не показывать ли данные. Я думаю, что в первом абзаце должно быть где-то, что код else должен go, но я действительно не знаю, где.
<?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; ?>
--
Igor helped me loads, but I wonder why this isn't working:
if (!empty($instagram)): ?><br />
<a class="author-ig" href="https://instagram.com/<?php echo $instagram ?>" target="_blank" rel="nofollow">@<?php echo get_the_author_meta('instagram'); ?></a>
if (!empty($twitter)): ?><br />
<a class="author-tw" href="https://twitter.com/<?php echo $twitter ?>" target="_blank" rel="nofollow">@<?php echo get_the_author_meta('twitter'); ?></a>
<?php endif; ?>
<?php else: ?>
ELSE_HTML_GOES_HERE
<?php endif; ?>