{"id":4324444,"date":"2013-11-16T14:02:44","date_gmt":"2013-11-16T14:02:44","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/add-custom-css-for-each-post-inside-a-category\/"},"modified":"2016-08-21T12:38:01","modified_gmt":"2016-08-21T12:38:01","slug":"add-custom-css-for-each-post-inside-a-category","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/add-custom-css-for-each-post-inside-a-category\/","title":{"rendered":"Add custom css for each post inside a category."},"content":{"rendered":"<p>Hi all. I am developing a wordpress news theme. What I want to do is add custom color to each category. At the end of the category template I have the following code,<strong> which works fine<\/strong>. This code add custom colors for each category (When user create a category, it choose a background color &#8211; I added an extra field there)<\/p>\n<pre><code>&lt;?php\n\t$category = get_queried_object();\n\t$category_id = $category-&gt;term_id;\n    $cat_data = get_option(&quot;category_$category_id&quot;);\n   if($cat_data[&#039;catBG&#039;]){\n?&gt;\n&lt;style&gt;\nsome css code\n&lt;\/style&gt;\n&lt;?php  }?&gt;<\/code><\/pre>\n<p>So far so good, but for example, if a user click a news inside the <strong>Sports Category (which background is green)<\/strong>, when in the news single section, the css code <strong>returns to default (which color is red<\/strong>). I want the <strong>green css<\/strong>, for the news (inside the spors category) as well. <\/p>\n<p>I hope what I said it make sense.<\/p>\n<p>Thanks in advance.<\/p>\n","protected":false},"template":"","class_list":["post-4324444","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4324444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4324444\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4324444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}