如何给回声一个“div class”?

问题描述:

试图添加一个css类到我的回声样式,我已经尝试了一些变化,但它没有奏效。如何给回声一个“div class”?

这是当前代码行,我使用:

<?php echo get_avatar(get_the_author_meta('ID') , 32); ?> 
+0

[get_avatar]的文档(https://developer.wordpress.org/reference/functions/get_avatar/)有一个允许您设置类的选项参数。 –

get_avatar的最终参数是含有各种选项,包括追加一个类的能力的阵列。

echo get_avatar(get_the_author_meta('ID') , 32, '', '', array("class"=>"your class"));

的全部细节见https://developer.wordpress.org/reference/functions/get_avatar/

另一方面,如果你只是想将现有的输出封装在一个div中,那么你只需要将它包装在div标签中即可。 echo "<div class='bla'>".get_avatar(get_the_author_meta('ID') , 32)."</div>";