How to style — get_the_category_list(' ') — using a css pseudo class?
-
Hey guys,
I have a question that’s closely related to another topic I’ve posted a few days ago. The issue got solved, thanks to you guys. I’m using the Thematic Theme framework and am currently building a child theme based on that.
The issue is quite the same. But now I’d like to style the category tag that pop’s up below posts. Jan Dembowski helped me out with his code and it works like a charm. I’m now able to style each post tag as desired. I’d like to do the same with the category-tags. So say a post got published under the categories “Blog” and “Current affairs” I’d like that to show up below the post in seperate boxes instead of just text seperated by commas. Therefore I need to be able to style (and basically wrap) each category tag in a
<div>
See Jan’s code that I’ve put in my functions.php and that worked, below:
add_filter( 'term_links-post_tag' , 'mh_add_wrap' ); function mh_add_wrap( $c ){ foreach( (array) $c as $k => $v ){ $a[] = '<span class="tags_style">' . $v . '</span>'; } return $a; }
…when I’m calling get_the_tag_list() it shows up like this:
<span class="tags_style"><a href="https://. . ./tag/tag1/" rel="tag">Tag1</a></span>
Which is exactly what I intended. I would be over the moon, if I could do the same thing with the category tags.I’m completely new to PHP so I was wondering, if a filter could be called, and if there’s a similar approach for the category tags available, which I managed to call via:
get_the_category_list(' ');
in my childthemes functions.phpCheers ??
- The topic ‘How to style — get_the_category_list(' ') — using a css pseudo class?’ is closed to new replies.