Answer the question
In order to leave comments, you need to log in
How to display WordPress username?
I'm trying to display the username in the card, but the function itself is displayed.
Name output
$current_user = wp_get_current_user();
$username = $current_user->display_name;
echo $username;
echo '<div class="demo-card-wide mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">
<?php
$current_user = wp_get_current_user();
$username = $current_user->display_name;
echo $username;
?>
</h2>
</div>
<div class="mdl-card__supporting-text">
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" href="/account">
Аккаунт
</a>
</div>
<div class="mdl-card__menu">
<button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect" onclick="location.href=\'/auth/?action=logout\'">
<i href="/?action-rcl=logout" class="material-icons">exit_to_app</i>
</button>
</div>
</div>';
Answer the question
In order to leave comments, you need to log in
$current_user = wp_get_current_user();
$username = $current_user->display_name;
echo '<div class="demo-card-wide mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">' . $username . '</h2>
</div>
<div class="mdl-card__supporting-text">
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" href="/account">
Аккаунт
</a>
</div>
<div class="mdl-card__menu">
<button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect" onclick="location.href=\'/auth/?action=logout\'">
<i href="/?action-rcl=logout" class="material-icons">exit_to_app</i>
</button>
</div>
</div>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question