我有一个从早上开始就无法解决的问题。
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
这是 index.php 中的 wordpress the loop
。当我添加the_post
页面中的最后一个帖子时,它会消失,当我删除它时,所有帖子都会混淆。
你能给我一个解决方案吗?
这是完整的 index.php
<?php get_header(); ?>
<div id="body">
<div class="content-container">
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="content-whole">
<div class="thumbnail">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
</div>
<div class="content">
<div class="post-title">
<p class="postmetadata">
Posted<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';?>
with <a href="#disqus_thread"><?php the_post(); comments_number(); ?></a>
<?php } ?>
</p>
<h2 id="post-title">
<a href="<?php the_permalink() ?>" rel="bookmark">
<?php
$cats=get_the_category();
echo $cats[0]->cat_name;
?> : <?php the_title(); ?></a></h2>
</div>
<?php the_content('Read More »'); ?>
</div><!--end content-->
</div><!--end content whole-->
<?php endwhile; ?>
<div class="pagenavi">
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>