Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm getting a page not found when I click on page 2 using wp-pagenavi. This is my code, is there anything obvious there that's wrong?

                <div class="news-content-inner">
                    <?php $portfolioloop = new WP_Query( array( 'paged' => get_query_var('paged'), 'post_type' => 'news', 'posts_per_page' => 4 ) ); ?>
                    <?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>
                    <div class="news-item" onclick="location.href='<?php echo the_permalink(); ?>'">
                        <h2><a href="<?php echo the_permalink(); ?>"><?php echo the_time('d.m.Y'); ?> / <?php echo the_title(); ?></a></h2>
                        <p class="news-page">
                            <?php if (get_field('description') != "") { ?>
                                <?php echo the_field('description'); ?>
                            <?php } else { 
                                $newscontent = get_the_content();
                                $newscontent_str = strip_tags($newscontent, '');
                                echo substr($newscontent_str,0,250) . "…";
                            } ?>    
                        </p>
                    </div>
                    <?php endwhile; // end of the loop. ?>

                    <p class="news-page" style="font-size:12px!IMPORTANT;"><?php echo wp_count_posts('news')->publish; ?> news items</p>
                    <?php if (function_exists('wp_pagenavi')) {
                    wp_pagenavi( array( 'query' => $portfolioloop ) ); } ?>
                </div>  

UPDATE:

I tried the following:

I saved the permalinks again as that usually solves any problems like that but that didn't work so I set permalinks to default, saved, that worked for the pagination but now clicking on a post had a 404. So set it to post name then saved again and it was just back to normal where the pagination wasn't working.

share|improve this question
    
What template is this in? –  Chris_O May 16 '12 at 10:48
    
@Chris_O It's a page template I've made called news-overview.php –  Rob May 16 '12 at 11:49

1 Answer 1

up vote 1 down vote accepted

I solved this by changing the urls... seems such a stupid mistake now!

I had the same url for the page as the taxonomy and they were clashing. As soon as I renamed the page url the pagination worked.

share|improve this answer

protected by toscho Jun 30 '12 at 13:14

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.