Answer the question
In order to leave comments, you need to log in
How to set a style class for labels in a WordPress theme?
Good afternoon. You need to give your WordPress tags custom styles.
With <?php the_tags(); ?> we display all the labels for the record, open the HTML and see that the classes of the labels are not registered. Whether it is possible to register a class to labels through function or in other other ways?
Answer the question
In order to leave comments, you need to log in
Maybe this code will work for you:
<?php
$tag_arr = array();
foreach (get_the_tags() as $tag)
{
$tag_arr []= '<a href="'.get_tag_link($tag->term_id).'" class="name_class">'.$tag->name.'</a>';
}
echo implode(',', $tag_arr);
$tag->term_id - tag ID
$tag->name - tag name
$tag->slug - alternative name
$tag->term_group - group the tag belongs to, if any
$tag->taxonomy - taxonomy. For this example, always 'post_tag'
$tag->description - the description of the tag specified in the settings
$tag->count - the number of entries for the tag
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question