我編輯了single.php以適應我的需求,它的工作原理。我只在循環的一部分留在其中如下:WordPress的側邊欄和循環php代碼扭曲對方
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div>
</div>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
它只裏顯示的文字,就像我希望它。 我得到的問題是當我添加以下代碼作爲模板中的側邊欄使用時;
<?php query_posts('showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>">
<?php the_title(); ?></a><br />
<?php endwhile;?>
它應該顯示最後10個職位的標題。但現在循環也顯示最新的(full0 10帖子,而不是隻屬於永久鏈接的一篇文章...我認爲一個變量左右正在被重用,需要休息..請注意,在single.php首先你得到「邊欄」代碼,然後你得到的「環」的代碼。
那麼,爲什麼WordPress的表現這樣?
也許嘗試query_posts前rewind_posts()()在你的側邊欄 – DCrystal 2010-04-28 17:26:10