WordPress.org

Ready to get started?Download WordPress

Forums

Post coloring (5 posts)

  1. freestyle_web
    Member
    Posted 9 years ago #

    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?

  2. dss
    Member
    Posted 9 years ago #

    I've done some fancy things with [p] styles for entries.

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

    maybe?

  3. iand
    Member
    Posted 9 years ago #

    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.

  4. freestyle_web
    Member
    Posted 9 years ago #

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

  5. lyklev
    Member
    Posted 9 years ago #

    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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.