2016-09-27 63 views
0

試圖添加一個css類到我的回聲樣式,我已經嘗試了一些變化,但它沒有奏效。如何給回聲一個「div class」?

這是當前代碼行,我使用:

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

[get_avatar]的文檔(https://developer.wordpress.org/reference/functions/get_avatar/)有一個允許您設置類的選項參數。 –

回答

1

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>";