0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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