Adding class to gravatar img in wordpress

后端 未结 4 1786
北恋
北恋 2021-02-08 13:26

I\'ve been trying to use get_avatar to display the author\'s gravatar under each post in wordpress template with applied class but I couldn`t find a way to add

4条回答
  •  深忆病人
    2021-02-08 14:02

    I think the best way to handle this would be to use a filter, rather than using jQuery as George suggests. You would simply add this to your theme's functions.php file.

    add_filter('get_avatar','add_gravatar_class');
    
    function add_gravatar_class($class) {
        $class = str_replace("class='avatar", "class='avatar pic-2", $class);
        return $class;
    }
    

    *Note, I've not tested this, but believe it will work. See this thread for more info.

提交回复
热议问题