WordPress.org

Ready to get started?Download WordPress

Forums

Conditional tags (5 posts)

  1. dewall
    Member
    Posted 8 years ago #

    I have tried to use conditional tags in my sidebar.php to show certain content for certain pages

    <li><?php /* If this is the frontpage */ if ( is_home() ) { ?>
    <h2><?php _e('Om vondewall.com'); ?></h2>
    <p class="test">V&auml;lkommen till <strike>v&aring;r</strike> Gustafs lekstuga p&aring; webben.
    H&auml;r hittar Tobias och Toves sl&auml;ktingar och v&auml;nner i n&auml;r och fj&auml;rran
    bilder s&aring; de kan f&ouml;lja med i vad som h&auml;nder i Tobias och Toves liv.
    </li>
    <?php } ?>

    <li><?php /* If this is the Arkiv */ if ( is_page(42) ) { ?>
    <h2><?php _e('Om arkiven'); ?></h2>
    <p class="test">H&auml;r kan du leta i v&aring;rt arkiv f&ouml;r att hitta exakt vad du s&ouml;ker.
    Arkiven &auml;r sorterad &aring;rs- och m&aring;nadsvis. Du kan &auml;ven g&aring; igenom alla nyheterna baserade p&aring; vilken kategori de har sorterats in under.
    </li>
    <?php } ?>

    etc

    In my sidebar I have used this approach set up conditional tags för för 6 pages.

    My idea was to use the tags to show a description based on the page the visitor was viewing.

    In Firefox and Safari this aproach works fine. In Interner Explorer, however, the right content in the sidebar is shown but the design is messed up. It seems as Internet Explorer leaves a blank space för the conditional tags that are not shown.

    Any suggestions on how to solve this?

  2. pcmt
    Member
    Posted 8 years ago #

    I'm not sure, but maybe the conditional tag should come before the list tag, instead of being inside it.

    <?php /* If this is the Arkiv */ if ( is_page(42) ) { ?>

    List...

    <?php } ?>

  3. dewall
    Member
    Posted 8 years ago #

    You are a genious!!! It worked. Thanks for your help

  4. skiene
    Member
    Posted 8 years ago #

    I got a quite similar problem:
    When I use <?php if ( is_home() ) { ?> to have a different formatting for the individual posts, my sidebar in which the conditional tag is used shows double when is_home is filled, but only in Internet Explorer.

    Any suggestions? ;)

    The site is http://www.nachtjournal.com

    Thanks for your help!

  5. lonelychina
    Member
    Posted 8 years ago #

    pcmt, the code you have posted seems to the one I was looking for. But, I am a newbie can you put the code little detailed?
    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic