1

Instead of outputting

<img alt="" src="#" srcset="#" class="avatar avatar-60 photo" height="60" width="60">

I want to add custom class which looks like

<img alt="" src="#" srcset="#" class="avatar avatar-60 photo myclass" height="60" width="60">

To achieve this, I tried to use

get_avatar( $comment, $args['avatar_size'], '', '', array('class' => 'myclass') );

However it doesn't change anything. Any help guys?

  • 1
    Perhaps the get_avatar filter is being run somewhere within the active theme or a plugin. This would modify the output of your call to get_avatar(). Try searching within the files for get_avatar. – Dave Romsey Nov 6 '18 at 22:51
0

The following worked for me:

<?php echo get_avatar( $comment, 60, '', '', $args = array( 'scheme' => 'https', 'class' => 'myclass' ) ); ?>

Your use of $args['avatar_size'] should be an int and you may have confused the use of this parameter (unless you have a variable $args, and it is an array).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.