La funzione di WordPress the_tags()
restituisce un elenco di tag sotto forma di stringa HTML. Possiamo aggiungere una classe CSS personalizzata a questa stringa utilizzando un filtro di WordPress. Vediamo come fare.
Aggiungete il seguente codice al file functions.php
:
function add_class_the_tags($html){
$postid = get_the_ID();
$html = str_replace('<a','<a class="test"',$html);
return $html;
}
add_filter('the_tags','add_class_the_tags',10,1);