WordPress.org

Support

Support » How-To and Troubleshooting » How can I specify a CSS class to a blog title?

How can I specify a CSS class to a blog title?

  • There are some posts I want to specify a specific CSS tag to in order to have a visual match to the topic I cover in the post. I tried it today, but it just mucked things up.

    Basically I want to be able to specify the class “Tulane” for posts I write about the Tulane baseball team at the College World Series. The CSS for that class is:

    .Tulane {
    color: #006633;
    font-weight: bold;
    }

    Is there a way to do this or am I trying to do the impossible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could try something like this:
    <h2 class="if ( in_category('category_id') ){
    echo "Tulane";
    } ?>">
    <?php
    the_title();
    ?>
    </h2>

    I’ll have to try that, although it could get unwieldy if I want to do specific classes for multiple categories. Thanks for the suggestion.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I specify a CSS class to a blog title?’ is closed to new replies.