2013-08-29 22 views
0

我想顯示一個特定類別的帖子作爲三列布局我有的問題是我不知道如何使用或forwach循環顯示每個發佈縮略圖,以便它可以使用one_thrid_last。 css類。獲得在wordpress中的縮略圖圖像和在3 coulmn中顯示

<?php while (have_posts()) : the_post(); ?> 
<?php if (is_category('actress-gallery')):?> 
<?php if (function_exists("has_post_thumbnail") && has_post_thumbnail()) : ?>  
<div class="one_fourth_last"> 
<a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0')); ?>" rel="bookmark"> 
<?php echo $image_url = wp_get_attachment_image(get_post_thumbnail_id($post->ID) , 'thumbnail'); ?> 
<h2><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 
     </a> 
    </div><!-- post-thumbnail /--> 

     <?php endif; ?> 
+0

did not get you question? – codepixlabs

+0

上面的代碼將按照垂直順序顯示該類別的所有帖子的縮略圖,我想要的是將圖像顯示爲每行3個圖像...就像一個網格...謝謝 – akkarthe

+0

表示在第一個顯示3個圖像行,然後轉移到下一行?等等 ? – codepixlabs

回答

0
<div class="wrapper" style="width:800px; height:auto;"> 

    <?php if (have_posts()) : ?> 
    <?php while (have_posts()) : the_post(); ?>  
    <?php if (has_post_thumbnail()) { ?> 
     <div class="image-wrapper" style=" width:250px; height:300px;" > 
      <?php the_title();?> 
      <?php the_content();?> 
      <?php the_post_thumbnail(); ?> 
     </div> 

    <?php } endwhile; endif; ?> 
</div> 
+0

對不起,它堅決地除了預期之外的東西,我想要做的就是通過1圖像一次到div類的三分之一循環,當它是每行3時,我要把它傳遞給div,最後一個三分之一。 – akkarthe

0
<div class="wrapper" style="width:750px; height:700px;"> 
<?php while (have_posts()) : the_post(); ?>  
<?php if (has_post_thumbnail()) { ?> 
<div style="width:250px; height:300px;" > 
    <?php the_title();?> 
    <?php the_post_thumbnail(); ?> 
</div> 
<?php } endif; ?> 
</div> 
0

你可以使用一個$count變量,並檢查第三縮略圖。

<?php if (have_posts()) : ?> 
    <?php $count = 1; ?> 
    <?php while (have_posts()) : the_post(); ?> 
     <?php if (has_post_thumbnail()) : ?> 
      <?php if ($count % 3 == 0) : ?> 
       <div class = "one_third_last"> 
      <?php else : ?> 
       <div class = "other_class"> 
      <?php endif; ?> 
        <?php the_title();?> 
        <?php the_content();?> 
        <?php the_post_thumbnail(); ?> 
       </div> 
     <?php endif; ?> 
     <?php $count++; ?> 
    <?php endwhile; ?> 
<?php endif; ?> 
相關問題