2012-02-01 7 views
1

Wordpressで、あるカテゴリーのすべての投稿を表示するループをセットアップしようとしていますが、問題は私の 'next_posts_link'と 'previous_posts_link'が機能しません。彼らはページ間をうまく移動しますが、結果は常に最初のページと同じです。私のWordpressのnext_posts_linkがカテゴリループを除外していないのはなぜですか?

<?php get_header(); ?> 

<div id="main" role="main"> 

<?php 
if (is_home()) { 
query_posts("cat=-6");} //Exclude work posts (cat 6) from the news page 
?> 

<div class="inner"> 

<h1><?php trim(wp_title("")); ?></h1> 

<?php include ('sidebartwo.php'); ?> 

<section class="main-wrap twocol news"> 

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

<article class="box-style"> 

<time><?php the_time('M d') ?><span><?php the_time('Y') ?></span></time> 

<h2><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?> 
</a></h2> 

<?php the_content(''); ?> 

</article> 

<?php endwhile; ?>        

<div class="next-prev-wrap"> 

<!-- This is what isn't working properly --> 
<span class="next"><?php next_posts_link('Older posts', $post->max_num_pages); ?></span> 
<span class="prev"><?php previous_posts_link('Newer posts', $post->max_num_pages); ?> 
<!-- /end --> 

</span> 

</div> 

</section>  

<?php endif; ?> 

</div> <!-- /inner --> 

</div> <!-- /main --> 

<?php get_footer(); ?> 

私は右の構文を使用していないと思う、実際にはWPのコーデックスのページによると、私も私の次/前のリンクは、私はそれがしたいように動作することができないと思います。私はこれにどのようにアプローチすべきですか?

+1

:私の新しいコードは次のようになります参考のためhttp://www.dynamicwp.net/articles-and-tutorials/pagination-problem-when-excluding-certain-category-from-blog-main-page/

:後くらい(と私はあまり意味が)グーグルで、私は私の問題を解決し、この記事を見つけました「あなたの答え」セクションを使用して、質問を編集する代わりにそれを受け入れたものとしてマークする必要があります。 –

答えて

4

自分自身を修正しました。この投稿は今解決されました。あなたがあなた自身の質問への答えを発見した場合は

<?php get_header(); ?> 

<div id="main" role="main"> 

<?php 
if (is_home()) { 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts("cat=-6&paged=$paged"); 
} 
?> 

<div class="inner"> 

<h1><?php trim(wp_title("")); ?></h1> 

<?php include ('sidebartwo.php'); ?> 

<section class="main-wrap twocol news"> 

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

<article class="box-style"> 

<time><?php the_time('M d') ?><span><?php the_time('Y') ?></span></time> 

<h2><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2> 

<?php the_content(''); ?> 

</article> 

<?php endwhile; ?>        

<div class="next-prev-wrap"> 

<span class="next"><?php next_posts_link('Older posts', $post->max_num_pages); ?></span> 
<span class="prev"><?php previous_posts_link('Newer posts', $post->max_num_pages); ?></span> 

</div> 

</section>  

<?php endif; ?> 

</div> <!-- /inner --> 

</div> <!-- /main --> 

<?php get_footer(); ?> 
+0

答えは私の答えに掲載されたコードスニペットです...?リンクはちょうど私がコードを入手した場所です。 – egr103

関連する問題