Kburrows
Member
Posted 4 months 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!
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. :)
Kburrows
Member
Posted 4 months 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.
Dankicity
Member
Posted 3 months ago #
is_home refers to the blog's home. For a static front page you're looking for is_front_page()
Kburrows
Member
Posted 3 months 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>
Dankicity
Member
Posted 3 months ago #
Simple Typo. Put the last endif back in and swap out
<?php if (!is_front_page() ); ?>
with
<?php if ( !is_front_page() ) : ?>