match a category id in wordpress and then add styles just for that id

this is in template-parts/content.php which may be different based on your theme or version of wordpress. 

you can locate the category id in wordpress by going into categories and then clicking the category or mousing over it and viewing the TagID for the following example its 2


// content.php
$post_id = get_the_ID();
$category_array = get_the_category( $post_id );
$category_id = $category_array[0]->term_id;

<?php if($category_id == 2) { ?>
.my-page-header {
<?php } ?>

Page Views

This page has been viewed 69 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
I believe that success can be measured in the number of uncomfortable conversations you're willing to have.