これは私のサンプルサイトhttp://box7.host1free.com/~avodes/で、ブログ投稿(blog.php)に問題があります。 「古いエントリ」のリンクをクリックしても、5つの新しい投稿はまだ古い投稿の代わりに表示されています。ここでWordPressのquery_posts()に古い投稿が表示されない
は私のコードです:
blog.php
<?php
/*
Template Name: Blog-2
*/
?>
<?php get_header(); ?>
<?php query_posts(array(
'posts_per_page' => 5,
'cat' => '1',
'paged' => (get_query_var('page') ? get_query_var('page') : 1),
));
?>
<div id="main-content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php include (TEMPLATEPATH . '/inc/meta.php'); ?>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in <?php the_category(', ') ?> |
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/inc/nav.php'); ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
</div>
<?php get_footer(); ?>
サイドノート: 'query_posts'の使用を避けるhttp://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-preget-posts/50762#50762 – janw