WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page 2, 3, 4, etc Display Content of Main Page. HELP! (8 posts)

  1. Tranny
    Member
    Posted 5 years ago #

    I don't know which part I had messed up, but when I click on "Previous Page" which takes me to Page 2 of the list of entries, I only see the same entries as on main page displayed.

    The URL changes and contains ...page/2/ at the end, Title tag changes as well and contains - Part 2 - behind the title. The only catch is that the same posts that appear on the main page are displayed. It does not display older posts. Anyone know what it is I have messed up that content of each older page displays the same, latest posts?

  2. stvwlf
    Member
    Posted 5 years ago #

    Did you by any chance put a query_posts() on that page?

  3. Tranny
    Member
    Posted 5 years ago #

    I may have, I've done some modifications to the theme in order to exclude some categories from displaying on certain pages. I did my own search for solution and followed instructions I have found. Obviously I messed something up big time :(

    What should I be looking for as the cause of the issue?

  4. stvwlf
    Member
    Posted 5 years ago #

    I was helping someone with the identical symptoms the other day and found a solution.

    Find your query_posts statement - from what you describe sounds like it would be in your theme's index.php

    Put this line of code before the query_posts statement

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    
    Now you must modify your query_posts line.
    
    If it looks like this as example
        query_posts("cat=1"); ?>

    paste this &paged=$paged in so it now looks like this

    query_posts("cat=1&paged=$paged"); ?>`

    Whatever the query_posts line is, paste &paged=$paged just before the closing quote or apostrophe. This tells WP to page the posts it has selected in the way you want it to.

  5. Tranny
    Member
    Posted 5 years ago #

    I've tried it, for some reason it hasn't worked. However you are obviously pointing me the right direction. This is the statement I have included in the index.php file:

    <?php query_posts('cat=-1,-91'); ?>

    It did the job I wanted form it - it excluded two categories from displaying in results. However the downside it was that older pages displayed the same content as first page. I have modified the code into your suggested statement so the final render looks like this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php query_posts('cat=-1,-91&paged=$paged'); ?>

    For whatever reason it has not solved the problem and all older pages still display the same posts as the main page. The issue is definitely there, because after I've removed that while statement, old pages display older posts as per correct order. But now it also displays posts in categories I don't want.

    Any idea what is wrong with that statement still that it doesn't work?

  6. stvwlf
    Member
    Posted 5 years ago #

    Sorry, one thing I forgot...
    change this
    <?php query_posts('cat=-1,-91&paged=$paged'); ?>
    to this
    <?php query_posts("cat=-1,-91&paged=$paged"); ?>

    Doesn't look like much difference but it means something very different to PHP

  7. Tranny
    Member
    Posted 5 years ago #

    Now it works. Thank you so much for your help, Steve :o)

  8. brandondrury
    Member
    Posted 4 years ago #

    That did the trick for me, too once I change it to ".

    Thanks!

    Brandon

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags