WordPress.org

Support

Support » Themes and Templates » Post coloring

Post coloring

  • I was wondering if there was a way to have posts different colors depending
    on what they were labeled. For example if I had a post under “stuff” I would want it to appear green. And if I had a post under “life” I would want it blue…is this possible to do in wordpress?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’ve done some fancy things with [p] styles for entries.

    it’s a css trick, not a WP mod or plugin.

    maybe?

    From the codex loop page: http://codex.wordpress.org/The_Loop

    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    I am guessing you could extrapolate this:
    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php elseif ( in_category('4') ) { ?>
    <div class="post-cat-four">
    <?php elseif ( in_category('n') ) { ?>
    <div class="post-cat-n">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    I am guessing with the elseifs, but the logic seems sound enough. Someone might know the right syntax.

    Does anyone know why this gives a parse error? It looks fine to me.

    A couple of }‘s are missing.

    an alternative, less error-prone way is the fortran-style:


    <?php if ( in_category('3') ) : ?>
    <div class="post-cat-three">
    <?php elseif ( in_category('4') ) : ?>
    <div class="post-cat-four">
    <?php elseif ( in_category('n') ) : ?>
    <div class="post-cat-n">
    <?php else : ?>
    <div class="post">
    <?php endif; ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post coloring’ is closed to new replies.
Skip to toolbar