Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #20337


    I’ve done some searching and haven’t quite found the answer I’ve been looking for…hopefully this is a modification that can be easily added to Chioices.

    I’ve created a blog page in my site using the dynamic template editor and labeled it “News”. Within those settings I selected 3 categories of posts I’d like to display on the News page. All the posts display as intended.

    I want to be able to style each <h2> Post title uniquely according to the post’s Category it’s been assigned. Right now there is a class of “post-title” attached to the <h2>…I’m hoping to add the post’s unique category to that class (or within that post’s div class) to be able to change colors for the text or possibly add backgrounds unique based on the category assigned.


    (on the “News” page displaying all categories)

    Post category is “Kermit”, I want that post title’s <h2> to be green

    Post category is “Gonzo”, I want that post title’s <h2> to be blue


    I can handle the css styles, I’m just not sure how to setup the hook(s).

    I’ve seen several posts about styling Category pages…not what I’m looking for.

    Appreciate the time!



    First, open includes > loop-index.php and find this code and remove it

    $current_post['title'] = get_the_title();

    Then go to this code on line 101

    echo $title;

    Replace it with

    //echo the post title
    foreach((get_the_category()) as $category) {
    echo '<h3 class="' . $category->cat_name . '"><a href="' . the_permalink . '" />';
    echo '</a></h3>';

    Example you have the category “Uncategorized”. You can use this on your custom.css to change the color.

    h3.Uncategorized {
    color: red;

    Then for category “News”, you can use

    h3.News {
    color: green;



Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Custom Blog Title Styles based on category assignment?’ is closed to new replies.