Using this code on my WP site and need help styling the echo lines of code;
`<?php
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
if ( ($current_user instanceof WP_User) ) {
echo '' . esc_html( $current_user->display_name );
echo get_avatar( $current_user->ID, 38 );
}
}
?>`
Would like to use CSS classes, but when I try the below code it doesn’t work;
echo '<p class="CSS Style">' . ($current_user->display_name ) '</p>';
Thanks to anyone that can help. Probably pretty simple to most developers.
3
Answers
I try run your code, i think you are missing the ‘ . ‘ before
</p>
.echo '<p class="CSS Style">' . ($current_user->display_name ) . '</p>';
Hey you can also do something like this if you want write a standalone P tag outside the PHP logic.
Otherwise, you can only add a dot before P closing tag.
Use this line of code
Your forgot to give period(.);