2011-10-13 104 views
-1

好的,這是我的問題。我希望能夠使用get_header_image和Nivo Slider在自定義標題之間切換。有一次我做了這個工作,將代碼合併到If ... Elseif ... Else語句中。現在我無法複製它。當前的代碼顯示標題圖像和它下面的滑塊。任何幫助將不勝感激。Wordpress get_header_image和Nivo滑塊切換 - PHP如果其他語句?

<?php 
// Check if this is a post or page, if it has a thumbnail, and if it's a big one 
if( 
    is_singular() 
    && current_theme_supports('post-thumbnails') 
    && 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); 
elseif (get_header_image()) : 
?> 
    <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; 
$wp_query = new WP_Query(array ('post_type'=>'page','post__in'=>array(1814))); 
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><!-- close #slider --> 

回答

0
<?php 
if( 
    is_singular() 
    && current_theme_supports('post-thumbnails') 
    && 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) 
{ 
    echo get_the_post_thumbnail($post->ID); 
} 
elseif (get_header_image()) 
{ ?> 
    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height=" <?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /> 
<?php } ?>