0

朝から解決できなかった問題があります。

<?php 
if (have_posts()) :
 while (have_posts()) : the_post(); ?>

the loopこれはindex.php のwordpressです。ページにある最後の投稿を追加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 &raquo;'); ?>
    </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>
4

2 に答える 2

0

表示するのは完全なループではありません。残りのロジック、つまりステートメントが欠落endwhileしています。endif

これは、 http: //codex.wordpress.org/The_Loop_in_Actionの最も基本的なWordpressループです。

<?php
get_header();
if (have_posts()) :
   while (have_posts()) :
      the_post();
      the_content();
   endwhile;
endif;
get_sidebar();
get_footer(); 
?>

そのリンクのドキュメントを読んで、ループを修正し、さまざまなWordpressループを構築する方法を確認してください。

于 2012-11-08T18:31:20.023 に答える
0

done i solved it by removing the_post(); from

<a href="#disqus_thread"><?php the_post(); comments_number(); ?></a>
于 2012-11-09T18:45:56.893 に答える