I need to add HTML to the Category names within my WordPress theme, so that I can define the name as an icon (via the Twitter bootstrap).
Example code as follows:
<a href="link">
<i class="icon-briefcase"></i>
</a>
This would present the Category name as a linked icon.
Is there any way to do this. I’ve searched endlessly and the only WordPress plugins I can find allow HTML to be added to the Category description only.
Thanks in advance.
I think what you’re trying to do you can easily solve like this:
This will make all the category names appear like linked icons, like you said. If you want each name to have a different icon you can of course add a conditional statement to render different HTML based on the category name or ID.
EDIT:
Because you want to use the Twitter Bootstrap, you need to assign css classes to the links in order to the display the icon. There are two ways you can do this. One of ’em being that you could name your categories the same as the icons. For example, a category named ‘briefcase’, would render a link with the class ‘icon-briefcase’. The code:
The second way, and I think a bit better for content purposes (more freedom for choice of cat names), would be to use a conditional statement in the code to assign icons to certain categories. For example:
I hope this is clear enough.
I think what you want is just the Category Icons plugin.
I just had a similar kind of requirement to add a big capital letter at the beginning on some category names, (but not others) in the same list. The easiest way I found of doing this was using CSS. This is what I ended up doing
You could probably impliment a very simple workaround using this method without knowing any php coding or installing any extra plugins. you’ll just need to inspect the html code of the generated page to get the class names and id’s you need.