• Hi Everyone,

    Left to my own devices I have not been able to successfully get this working. I want to find a way to switch between the native WordPress Header and a Nivo Content Slider.

    (So if no Header is selected the default displays the Nivo Content Slider or vice versa.)

    It was suggested that I wrap everything in IF/Else, but I’m not too good with PHP. I’m lost. Here’s my code.

    <div id="branding" role="banner">
    				<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    				<<?php echo $heading_tag; ?> id="site-title">
    					<span>
    						<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    					</span>
    				</<?php echo $heading_tag; ?>>
    				<div id="site-description"><?php bloginfo( 'description' ); ?></div>
    
    <?php
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else : ?>
    						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    					<?php endif; ?>
    
    <div id="slider">
    <?php
    $tmp = $wp_query;
    $args = array(
    	'post_type' => 'page',
    	'post__in'  => array( '16' )
    );
    $wp_query = new WP_Query( $args );
    if(have_posts()) :
        while(have_posts()) :
            the_post();
    ?>
                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('nivothumb'); ?></a>
    <?php
    endwhile;
    endif;
    $wp_query = $tmp;
    ?>
    </div>
    			</div><!-- #branding -->

    I’m using the Twentyten theme and right now both items are displaying.

    Thanks for any help,

    Dustin

  • The topic ‘IF/Else Banner Slider Switching’ is closed to new replies.