WordPress.org

Ready to get started?Download WordPress

Forums

How To Change The Background Colour of specific posts only? (6 posts)

  1. timesharestaff
    Member
    Posted 6 years ago #

    I am trying (but failing) to change the background colour of specific individual posts only - in a sense to highlight them so that they stand out from all the others on the page.

    How can I do this?

  2. jaiunblog
    Member
    Posted 6 years ago #

    hello,

    Maybe you can « hack » your template by add php
    <?php if (check the doc to color by name of post or cat == "red"){ ?>
    <div class="red">
    <?php }?>
    <? template feature >

    <?php if (check the doc to color by name of post or cat == "red"){ ?>
    </div>
    <?php }?>

  3. timesharestaff
    Member
    Posted 6 years ago #

    which template would I place this in and how do I select the specific posts that this would work on?

    Thanks

  4. DE
    Member
    Posted 6 years ago #

    You could make a special category for it and add the name of the category to you posts class attribute.

    <?php
    foreach((get_the_category()) as $cat) {
    echo $cat->cat_name . ' ';
    } ?>

    Then it's just a matter of making a special css rule for that class.

  5. jeremyduffy
    Member
    Posted 6 years ago #

    To flag the specific posts, why not just make a custom field? That's assuming the category idea doesn't work for you of course.

  6. jaiunblog
    Member
    Posted 6 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic