admin管理员组文章数量:1434371
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?
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?
Share Improve this question asked Nov 6, 2018 at 21:47 p onelandp oneland 171 silver badge8 bronze badges 1 |1 Answer
Reset to default 0The 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).
本文标签: theme developmentAdding custom class to getavatar() image doesn39t work
版权声明:本文标题:theme development - Adding custom class to get_avatar() image doesn't work 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745621747a2666725.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
get_avatar
filter is being run somewhere within the active theme or a plugin. This would modify the output of your call toget_avatar()
. Try searching within the files forget_avatar
. – Dave Romsey Commented Nov 6, 2018 at 22:51