Learn with this tutorial how to introduce the category as a custom CSS class in the body of your Genesis Framework child theme through 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.
Besides assigning your own styles to specific pages, you also have the option of adding a CSS class to the category. This way you can layout all the posts, products or courses included in the same category in the same way.
Find out how to do it:
Snippet to insert a category as a CSS class in Genesis
Add the following line in functions.php:
To see this and another 1097 code snippets of this website, login or subscribe here.
This fragment allows you to use the CSS selector “.category” to apply specific styles to the posts or CPTs within that taxonomy.
Conclusions
If you assign a CSS class to the category 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 layout those posts or CPTs.
Any questions? I read you 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. 😉