Forums

[resolved] How to grap page # from URL and pass in to query_posts? (4 posts)

  1. tastewar
    Member
    Posted 2 years ago #

    I'm trying to craft a page that will display one category's worth of posts, in fwd chronological order. It's close. It displays one page's worth of posts. If I click on the link for later entries, it displays "page 2" but the posts are the same. I believe I understand why -- my query_posts is always going to select the first set of matching posts. Somehow, I need to grab the page # from the URL and pass it in to query_posts. I think. Here is the current query:

    <?php query_posts("cat=12" . '&orderby=date&order=ASC'); ?>

    Can someone help me?

  2. JLeuze
    Member
    Posted 2 years ago #

    I don't think you can get pagination to work with query_posts, you might have to use a "regular" loop to get this to work like you want it to.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Try:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 12,
    	'orderby' => 'date',
    	'order' => 'ASC',
    	'paged' => $paged
    );
    query_posts($args);
    ?>
  4. tastewar
    Member
    Posted 2 years ago #

    Works! Thanks!!

Topic Closed

This topic has been closed to new replies.

About this Topic