2015-04-23 28 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个职位(这是上面显示的代码页)。 –