WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination problem (5 posts)

  1. SMae
    Member
    Posted 4 years ago #

    Hello,

    I am going mad trying to figure out the pagination for my front page.

    I want to display my latest single post from category 5 on my front page. I also want to be able to navigate through category 5 from the front page. Right now when there is more than one post page 2 results in a 404 error.

    My current code:
    <?php if ( is_front_page() ) {
    query_posts($query_string . 'posts_per_page=1&cat=5');
    } ?>

    Thank you for any help

  2. SMae
    Member
    Posted 4 years ago #

    Anyone?

  3. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    you have a condition on the query (is_front_page) - what if not?
    (could you show the code of the full index.php for more details?)

    if this is not the reason for the error message, you could try including the $paged variable:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . 'posts_per_page=1&cat=5&paged='.$paged);
  4. SMae
    Member
    Posted 4 years ago #

    Thank you for your reply.

    I just worked it out. The problem was that I could get the pagination to work with conditional 'posts_per_page=1' or '&cat=5' comments, but could not get it to work with both.

    So I downloaded the "Different Posts Per Page" plug-in and used the original code I had without the 'posts_per_page=1'.

    <?php if ( is_front_page() ) {
    query_posts($query_string.'&cat=5');
    } ?>

    I am sure there is a way to do it without the plug-in but I tried for hours and couldn't figure it out so Ill stick to this solution unless someone can tell me a better one.

  5. Mark / t31os
    Moderator
    Posted 4 years ago #

    There's a solution in the last reply..

Topic Closed

This topic has been closed to new replies.

About this Topic