Forums

Call Category Name/Title to be used as a CSS Selector (2 posts)

  1. afruit
    Member
    Posted 1 year ago #

    I'm building a tumblr-styled theme in wordpress, but I want to lay out the posts in the main blog timeline differently depending on category. To do so, I thought it'd be as simple as pulling the category name into class="_______" .

    The main "the_category" tag produces a link, with breaks the attempt to use it as a style, and I haven't had luck with "get_the_category".

    Anyone have ideas on this?

    NOTE: I'm not attempting to style the individual article/post pages differently. This I know how to achieve. Rather, I want to achieve a different look for each entry-category in the main blog timeline. Tumblr does this by default, by giving each post a class name equal to it's category.

  2. afruit
    Member
    Posted 1 year ago #

    So I've tried:
    <div class="<?php the_category( ); ?>">
    and:
    <div class="<?php get_the_category( ); ?>">

    Also, tried:
    <div class="<?php single_cat_title( ); ?>">

    None worked, but I'm not sure I'm using any of them correctly.

Topic Closed

This topic has been closed to new replies.

About this Topic