WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] previous/next page don't work (6 posts)

  1. tomboersma
    Member
    Posted 5 years ago #

    Hi,

    I'm making a website here for a local history-club: http://www.aurlandsogelag.no/

    On the artiklar page (articles) I can't get the page navigation to work: it seems to point to the correct page/2 and page/3 but always just shows the first 5 posts. I've studied the forums but didn't find a solution.

    The page is a template "artiklar.php" where I select the articles by using this code:

    <?php query_posts('cat=4');?>

    Can anybody help? Thanks!

  2. yoshi
    Member
    Posted 5 years ago #

    Codex › query posts › Usage:

    When you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category). If you want to preserve that information, you can use the variable $query_string in the call to query_posts().

    So need $query_string to preserve the paging info.

    <?php query_posts($query_string . '&cat=4');?>

  3. tomboersma
    Member
    Posted 5 years ago #

    Thanks for your fast help. Unfortunately it doesn't work: No articles are shown at all now...

  4. yoshi
    Member
    Posted 5 years ago #

    Oops. That was a Page template.

    Then you need to empty pagename and page_id params otherwise WP looks for a page named 'artiklar' and in category 4, which obviously doesn't exist.

    <?php query_posts($query_string . '&cat=4&pagename=&page_id='); ?>
  5. tomboersma
    Member
    Posted 5 years ago #

    That works, thanks a lot!

  6. cedosan
    Member
    Posted 5 years ago #

    Just what I was looking for, thanks !

Topic Closed

This topic has been closed to new replies.

About this Topic