How to add custom color fields to the category edit page?
I’m building a WordPress theme and I am currently finishing the category.php
page. For this page, I would like the user to select two colors (background color and title/text color) and use them in the category.php
page.
I searched on the internet for examples on how to do this, but I only found some pieces of code without explanation (example). I also encountered something about functions for custom fields being deprecated in WordPress.
Can anyone show me how I add two custom fields for color to each category and how I should apply that in the theme? Or point me to a guide on custom fields in WordPress?
I don’t want to use inline CSS, so I think that we should use wp_add_inline_styles
to apply the styling. So say that color 1 should be applied to .background
and color 2 to .title
for each different category, what would I put in my wp_add_inline_styles
?
Many thanks!
Leave an answer