How to add custom color fields to the category edit page?

Question

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!

0
, , , ralphsmit 1 year 2020-07-21T05:10:23-05:00 0 Answers 51 views 0

Leave an answer

Browse
Browse