0
I am trying to color the background of the link of each category, leaving each one of a color, but I wanted you to style ONLY the links of the categories on the homepage, I do not want to change the style on the page of the categories. It’s something I’m trying to do:
I was wondering if you could do that and if you could help me. That’s my code so far:
<div class="col-md-4">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="artigo">
<div class="post-header"><?php the_post_thumbnail( 'large'); ?></div>
<div class="icons-categ"><?php the_category('') ?></div>
</div>
<?php endwhile?> <?php else: ?> <?php endif; ?>
</div>
This is the code of the categories I have in css, but it doesn’t seem to work:
.category-noticias .icons-categ {
background: #e07737;
color:#fff;
}
.category-celebridades .icons-categ {
background: #1865e4;
color:#fff;
}
.category-musicas .icons-categ {
background: #aa0909;
color:#fff;
}
.category-filmes .icons-categ {
background: #b6e037;
color:#fff;
}
Note: I am using wordpress and bootstrap
I don’t know if it will work, but you can try in CSS to use Nth-Child, like this
[class*="category-"]:nth-child(1) .icons-categ {
 background: #e07737 !important;
 color:#fff !important;
}
and then you do it:nth-child(2)
,:nth-child(3)
for every category you have, it might work...– hugocsl