WordPress.org

Ready to get started?Download WordPress

Forums

Change icon if Private (4 posts)

  1. NullMind
    Member
    Posted 9 years ago #

    I am using the MX4 theme for wordpress

    http://www.mx4.info/devblog/

    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 ? :)

    Null

  2. Kafkaesqui

    Posted 9 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:

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

    http://codex.wordpress.org/Using_the_Support_Forums

  3. NullMind
    Member
    Posted 9 years ago #

    thanks

    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
    Member
    Posted 9 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

Tags

No tags yet.