Hey there CaptainCrunch,
According to the content on the http://codex.wordpress.org/Function_Reference/get_the_tag_list (scroll down to the “A Slightly More Complex Example” section:
You can add classes and styles with CSS, as necessary.
I’m assuming that you would have to insert your CSS selector into the $before
string. Perhaps something like:
<?php
if(get_the_tag_list()) {
echo get_the_tag_list('<p><span class="tags_style">',' ','</span></p>');
}
?>
I am pretty sure you are not going to get the CSS class code to insert into the actual anchor tag like you have in your example above.
See if that gets you closer to a solution which will work for ya!
Cheers.
Hey there James,
thanks for your reply. Unfortunately that didn’t solve my problem… I tried something quite similar (adding <div class="my_class"></div>
) in the middle part of the bracket. What it does then, is to write my div class before each <a href>
link instead of encapsulating it… And when I add the class like you did in your example, it addresses the whole block of links. Is there any other way to address each link? I’d like to add boxes to each tag/link — similar to what TheVerge does on their website…
Cheers.
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
It’s not quite the same as what you are looking for, but this will wrap each of the tag links like so:
<span class="tags_style"><a href="http://. . ./tag/tag1/" rel="tag">Tag1</a></span>
That way you may be able to style those links with CSS.
Add this to your theme’s functions.php
file.
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;
}
Then you can style the tag links.
span.tags_style a {
color: rgb(255, 0, 0);
}
Hey Jan,
finally! We got that sorted! Thanks so much, your code works like a charm 🙂
Cheers
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
I’m glad to help! I’m always a fan of re-using older solutions. 😉
I’m going to have to whip out a NotePad & check out Jan’s solution. As I look at it on my smart phone, I’m not asserting the difference to mine if the paragraph tags were removed. This it’s what I love about these forums, no matter how long one has been at it, there is ALWAYS more to learn! Thanks Jan!