Discover in this Genesis Framework tutorial how to introduce the tags as custom CSS classes in WordPress using code.
WordPress offers several CSS classes to help layout some pages, for example:
- .page
- .single
- .single-portfolio
- .post-type-archive-portfolio
But what if these predefined styles are not enough and you need something more specific?
In that case, the best solution is to create a custom CSS class.
Apart from assigning your own styles to the categories, you also have the option of adding a CSS class to the tags. This way you can layout all the posts, products or courses that are marked with a specific tag in the same way.
Find out how to do it:
Snippet to insert tags as a CSS class in WordPress
Add the following code snippet in functions.php:
To see this and another 965 code snippets of this website, login or subscribe here.
This fragment allows you to use the CSS selector “.tag-1”, “.tag-2”… to apply specific styles to the posts or CPTs within that taxonomy.
Conclusions
If you assign a CSS class to a tag it will be very easy for you to maintain a uniform style on the web and, for the same price, you will save time when it comes to laying out those posts or CPTs as you wish.
Even better, now you know how to do it with a simple code snippet.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉