[resolved] Paginate with get_option (3 posts)

  1. aldolat
    Posted 7 years ago #

    I have a page which lists all my "featured posts".

    To display these posts I am using this piece of code:
    <?php query_posts('cat=1&showposts='.get_option('posts_per_page')); ?>
    as written in the codex: http://codex.wordpress.org/Category_Templates#What_categories_do_you_show_to_the_visitors.3F

    This line shows me only my posts from category 1 and paginate them accordingly the wp-admin panel option.

    But when I go to the page #2 or #3, I view always the page #1.
    Why this?

  2. MichaelH
    Posted 7 years ago #


    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=1&showposts='.get_option('posts_per_page').'&paged=' . $paged);
  3. aldolat
    Posted 7 years ago #

    Thank you for your support! Your code works well. :)

    And also this modified version of your code paginate the posts correctly:
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=1&paged=$paged"); ?>
    without specifying the get_option but using the double quote (").

Topic Closed

This topic has been closed to new replies.

About this Topic