tea93
tea93

Reputation: 13

How to give an echo a "div class"?

trying to add a css class to my echo to style this, i've tried a few variations but it didn't work.

this is the current line of code that i'm using:

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

Upvotes: 0

Views: 921

Answers (1)

Carl
Carl

Reputation: 1816

The final param of get_avatar is an array containing various options, including the ability to append a class.

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

See https://developer.wordpress.org/reference/functions/get_avatar/ for full details.

If on the other hand you just want to wrap the existing output in a div, then you just need to wrap it in the div tag ie. echo "<div class='bla'>".get_avatar( get_the_author_meta( 'ID' ) , 32)."</div>";

Upvotes: 1

Related Questions