我有一個問題,我無法解決自上午。問題在wordpress循環
<?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>
向我們展示完整的代碼?你有'endwhile'和'endif'嗎? –