La funzione di WordPress the_tags()
genera un elenco di tag associati ad un post. Possiamo aggiungere una classe a ciascun tag utilizzando un filtro specifico. Vediamo come fare.
Aggiungete il seguente codice al file functions.php
, sostituendo la stringa class
con il nome della classe scelta:
function add_class_the_tags($html) {
$html = str_replace('<a','<a class="class"',$html);
return $html;
}
add_filter('the_tags','add_class_the_tags',10,1);