2014-01-11 12 views
0

我想顯示最近的帖子在一個塊中,如果該帖子分配有縮略圖,我希望它顯示在左側發佈內容。如何顯示縮略圖,如果發佈有其他明智的不要

這是我的代碼,我一直在試圖

   <?php query_posts('posts_per_page=1') ?> 
      <?php while (have_posts()) : the_post(); ?> 

       <div class="jumbotron"> 
        <?php if (has_post_thumbnail();)?> 
        <div class="col-md-3"> 
         <?php the_post_thumbnail(); ?> 
        </div> 
        <div class="col-md-9"> 
         <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
         <p><?php the_excerpt(); ?></p> 
         <p class="text-muted">Posted on <?php the_time('jS F, Y'); ?></p> 
       </div> 

        } 
       <?php else;?> 
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
        <p><?php the_excerpt(); ?></p> 
        <p class="text-muted">Posted on <?php the_time('jS F, Y'); ?></p> 
       </div> 

      <?php endwhile; wp_reset_query(); ?> 

希望有人能幫幫我!提前致謝!

+0

WordPress的問題通常是offtopic,在這裏嘗試http://wordpress.stackexchange.com – elclanrs

回答

0

你嘗試這樣的事情可能是有用的:

<?php 
    $args = array('numberposts' => '5'); 
    $recent_posts = wp_get_recent_posts($args); 
    if (has_post_thumbnail()) { 
    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id(),'large', true); 
    echo '<a href="' . $image_url[0] .'" title="' . the_title_attribute('echo=0') . '">'; 
    the_post_thumbnail(); 
    echo '</a>'; 
     } else { 
      echo 'test'; 
     } 
?> 
相關問題