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 recently developed a custom post type for my company's blog, so that we could have a separate press area. In the archive-presse.php page I make a query, thus :

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//echo '<div style="display:hidden"> paged :'. $paged . "</div>";
$press_articles = new WP_Query(
    array(
        'post_type' => 'presse', // Tell WordPress which post type we want
        'paged' => $paged,
        'orderby'   => 'post_date',
        'posts_per_page' => '10'
        )
    );

and at the bottom, I create the navigation links :

<div class="navigation">
<div class="left"><?php previous_posts_link('&laquo; Zurück',$press_articles->max_num_pages) ?></div>
<div class="right"><?php next_posts_link('Weiter &raquo;',$press_articles->max_num_pages) ?></div>
</div>

(Austrian website, in case you were wondering)

On the first page, this works fine; the posts appear and so does the navigation links, which points to the second page and so on. On the third page however, when I click on 'Weiter', I end up on the 404 page, although I am sure there are still articles to be shown.

My only fix at the moment is to make sure that the posts per page is equal to a third of the total number of posts. Not much of a fix.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The problem was that one cannot apparently set 'posts_per_page' to anything other than what is set in the admin interface, even for a custom archive page.

The same code, minus the 'posts_per_page' => 'x' line, works fine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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