WordPress.org

Ready to get started?Download WordPress

Forums

conditional NOT home condition tag (6 posts)

  1. Kburrows
    Member
    Posted 2 years ago #

    I"m using this piece of code and it works fine except I don't want it to show up on the home page. Everything I've tried issues a syntax error.

    I want it to be...if it's NOT the home page then do this.

    <div id="headerleft">
    <?php if ( isset ($swp_options['swp_logo']) &&  ($swp_options['swp_logo']!="") ) {
    ?>
     <div class="logo"><img src="<?php echo esc_attr(strip_tags($swp_options['swp_logo'])); ?>" alt="<?php esc_attr(strip_tags(bloginfo('name'))); ?>"  /></div>
     <?php } else { ?>
         <h1><?php esc_attr(strip_tags(bloginfo('name'))); ?></h1> <h5><?php esc_attr(strip_tags(bloginfo('description'))); ?></h5>
         <?php } ?>
     </div>

    Can anyone show me where and how to put the (!is_home() in??

    Much appreciated!

  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    Assuming you want all that code conditionalised, this should do it...

    <?php if( !is_home() ) : ?>
    <div id="headerleft">
    	<?php if( isset( $swp_options['swp_logo'] ) && ( !empty( $swp_options['swp_logo'] ) ) ) : ?>
    		<div class="logo"><img src="<?php echo esc_attr(strip_tags($swp_options['swp_logo'])); ?>" alt="<?php esc_attr(strip_tags(bloginfo('name'))); ?>"  /></div>
    	<?php else : ?>
    		<h1><?php esc_attr(strip_tags(bloginfo('name'))); ?></h1>
    		<h5><?php esc_attr(strip_tags(bloginfo('description'))); ?></h5>
    	<?php endif; ?>
    </div>
    <?php endif; ?>

    Hope that helps. :)

  3. Kburrows
    Member
    Posted 2 years ago #

    Thats what I thought would work, but I'm still getting the logo on the home page.

    I have the home set as a static page. Not sure why it's not working. The code is in the side bar, it should just be empty on the home page.

    Any other ideas? I appreciate your help.

  4. Dankicity
    Member
    Posted 2 years ago #

    is_home refers to the blog's home. For a static front page you're looking for is_front_page()

  5. Kburrows
    Member
    Posted 2 years ago #

    No joy - I deleted the 2nd endif it generated an error. The logo is still there regardless of the page.

    <?php if (!is_front_page() ); ?>
    <div id="headerleft">
    <?php if( isset( $swp_options['swp_logo'] ) && ( !empty( $swp_options['swp_logo'] ) ) ) : ?>
    <div class="logo"><img src="<?php echo esc_attr(strip_tags($swp_options['swp_logo'])); ?>" alt="<?php esc_attr(strip_tags(bloginfo('name'))); ?>" /></div>
    <?php else : ?>
    <h1><?php esc_attr(strip_tags(bloginfo('name'))); ?></h1>
    <h5><?php esc_attr(strip_tags(bloginfo('description'))); ?></h5>
    <?php endif; ?>
    </div>

  6. Dankicity
    Member
    Posted 2 years ago #

    Simple Typo. Put the last endif back in and swap out
    <?php if (!is_front_page() ); ?>
    with
    <?php if ( !is_front_page() ) : ?>

Topic Closed

This topic has been closed to new replies.

About this Topic