2015-04-23 48 views
0

任何人都可以嘗試此代碼? 看起來第25行和第44行有一些錯誤。是在home.php中,它提醒我在瀏覽器上只有一個空白頁面。 我不知道PHP,所以我cannota找到什麼問題,你可以幫我嗎?在這個wordpress循環中的錯誤

<?php 
if (is_front_page()) { 
     get_header('front'); 

} else { 
     get_header(); 
} 
?> 

<section id="content" class="container"> 
<div class="row"> 
<div class="col-md-7 col-sm-7"> 

<?php if (have_posts()) : while (have_posts()) : the_post(); 
if ($wp_query->current_post === 0) { ?> 
    <article class="thumbnail thumbnail-principale expand-image"> 
     <div class="featured-image"> 
      <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($post_id, 'large', array('class' => 'img-responsive')); ?></a> 
     </div> 
     <div class="destacado"><h3>Destacado</h3></div> 
      <header class="testo-articolo"> 
       <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
       <div class="entry-meta"> 
        <p class="text-muted resume"><span><i class="fa fa-calendar"></i><?php the_time('j M y'); ?></span><span><i class="glyphicon glyphicon-user"></i><?php the_author(); ?></span><span><i class="fa fa-comment-o"></i><?php comments_popup_link('0', '1 Comentario', '% Comentarios'); ?></span></p> 
       </div> 
       <p><?php the_excerpt(); ?></p> 
       <?php comments_template(); ?><!-- da sistemare --> 
      </header> 
    </article> 
</div> 

<?php 

} elseif ($wp_query->current_post >= 1 && $wp_query->current post <= 2) { ?> 

<div class="col-md-5 col-sm-5"> 
    <article class="thumbnail thumbnail-destra expand-image"> 
     <div class="featured-image"> 
      <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($post_id, 'large', array('class' => 'img-responsive')); ?></a> 
     </div> 
     <header class="testo-articolo-destra expand-image"> 
      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
      <div class="entry-meta"> 
       <p class="text-muted resume"><span><i class="fa fa-calendar"></i><?php the_time('j M y'); ?></span><span><i class="glyphicon glyphicon-user"></i><?php the_author(); ?></span><span><i class="fa fa-comment-o"></i><?php comments_popup_link('0', '1 Comentario', '% Comentarios'); ?></span></p> 
      </div> 
      <p><?php the_excerpt(); ?></p> 
     </header> 
     <div class="badge1"></div> 
    </article> 
</div> 
<?php 

} elseif ($wp_query->current_post >= 3) { ?> 

<div class="col-md-4 col-sm-4"> 
    <article class="thumbnail distanza expand-image"> 
     <div class="featured-image"> 
      <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($post_id, 'large', array('class' => 'img-responsive ingrandire-img')); ?></a> 
     </div> 
     <header class="testo-articolo"> 
      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
      <div class="entry-meta"> 
       <p class="text-muted resume"><span><i class="fa fa-calendar"></i><?php the_time('j M y'); ?></span><span><i class="glyphicon glyphicon-user"></i><?php the_author(); ?></span><span><i class="fa fa-comment-o"></i><?php comments_popup_link('Ningún comentario', '1 Comentario', '% Comentarios'); ?></span></p> 
      </div> 
      <p><?php the_excerpt(); ?></p> 
      <p><a class="btn btn-default read-more" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php _e('Lee más', 'katartika'); ?></a></p> 
     </header> 
    </article> 
</div> 

<?php } 

endwhile; 
endif; ?> 


</div><!-- /row --> 
<div style="text-align:center;"> 
<?php posts_nav_link(‘|’, ‘Prossimo’, ‘Precedente’); ?> 
</div> 
</section> 
</div><!-- /sezione --> 
<?php get_footer(); ?> 
+0

並啓用[調試](https://codex.wordpress.org/Debugging_in_WordPress)? – d79

回答

0

有一個簡單的PHP錯誤。將它們固定爲波紋管。 號線34 使用此代碼

} elseif ($wp_query->current_post >= 1 && $wp_query->current_post <= 2) { ?> 

號線79 使用此代碼

<?php posts_nav_link('|', 'Prossimo', 'Precedente'); ?> 
+0

謝謝,它的作品! 你能幫我分頁,還是我不得不問一個新問題? –

+0

問下面的問題給所有的信息 – Ajith

+0

我需要從第二頁起不同的佈局,我希望它顯示6個職位,就像第一頁中的最後6個職位(這是上面顯示的代碼頁)。 –