php - how to get avatar on front end wordpress


Hello users of stack over flow, I have a little Question,

I am trying to get avatar in upper end of my website, if user is logged in I want to show

avatar and name and link to profile,

if user is not logged in I want to show login and register buttons

I know little bit of php only , I will have to use if else statement but how to call wordpress logged in user function ,


(if you provide me with a sample code that will help a lot)

I tried something like this

But I got erros , Please can someone tell me what I am doing wrong




For example;

    if ( is_user_logged_in() ) {
        if (function_exists('get_avatar')) { 
          echo get_avatar( get_the_author_meta('user_email'), 68 );
   } else {
       echo '<a href="'.wp_login_url( get_permalink() ).'" title="Login">Login</a>

Your code must be like this,

People are also looking for solutions to the problem: Run powershell in php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.