Change icon if Private (4 posts)

  1. NullMind
    Posted 11 years ago #

    I am using the MX4 theme for wordpress


    what I wanted to do is to make the "pen1.gif" icon change to somethign else "pen2.gif" when the entry is a private one

    can that be done ? :)


  2. Kafkaesqui

    Posted 11 years ago #

    As the gif is a background image assigned through css to the post title's <h2> tag, you'll have to attack this in two places.

    1. Modify your theme's style.css, changing h2.pen to h2.pen1, and adding a new class declaration:

    h2.pen2 {
    margin-bottom: 1px;
    margin-left: 0px;
    padding: 6px 2px 2px 24px;
    background: url(images/pen2.gif) no-repeat 0px 4px;

    2. At the start of The Loop in your theme's template(s), you'll want to insert this bit of PHP:

    if('private' == $post->post_status) {
    $pen = 'pen2';
    } else {
    $pen = 'pen1';
    } ?>

    You also need to alter the opening <h2> tag, so it's:

    <h2 class="<?php echo $pen; ?>" id="post-<?php the_ID(); ?>">

    Note on forum posting: please don't post the same question multiple times. If you're new to WordPress and the forums, this Codex page is recommended:


  3. NullMind
    Posted 11 years ago #


    it all works great for the main page, but when you go to "archives" the pen icon disapeered all togueder .. am I missing somehting ?

  4. NullMind
    Posted 11 years ago #

    oops, I got it

    had to do the same exact thign for archive.php as I did for index.php :)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.