[resolved] Archive does not work anymore (displays only the two most recent posts) (7 posts)

  1. Nuuzeli
    Posted 2 years ago #

    First of all I'd like to say I'm really bad at PHP and anything I do, I do by trial and error. Therefore I always face these sort of simple problems. Anyway...

    I made a website with an archive that displays the 100 most recent posts using

    <?php global $more;
    $more = 0;

    The website's front page, however, was limited to two posts. That I did through the WordPress settings, where I set the limit of posts on front page to two.

    This all worked great. No problems whatsoever. Well, now that I did a second website where I used the exact same code, it won't work. The second website is otherwise identical to the first, but it has two separate archives that divide the posts into two different categories. The other one shows general news and the other (football) games news. For some weird reason these archives will only show two most recent posts, just like on the front page. When I go to WordPress settings and change the limit of posts on front page to, for example, three, the archives also show three posts.

    The code I have on the second website is this (the only difference is the cat=3)

    <?php global $more;
    $more = 0;
    query_posts('cat=3', 'showposts=100');

    So my question is, why does the showposts=100 work on the first website, but not the second?

  2. wpbum
    Posted 2 years ago #

    Is it the exact same theme? Maybe the theme is controlling how many posts are being shown.

    What does it show if you remove cat=3?

  3. Nuuzeli
    Posted 2 years ago #

    Yes, this is the exact same theme I built from scratch. It's a VERY simple theme and doesn't even have search, 404, etc.

    If I remove the cat, both archives display all posts from both categories. When the cat is removed, showposts=100 works, but when I put the cat back, it stops working. So weird.

  4. wpbum
    Posted 2 years ago #

    Next I'd just check to see if the cat ID is correct and try the other one to see if it produces the same results or the correct query.

  5. Nuuzeli
    Posted 2 years ago #

    The ID's are correct. The general news archive displays posts from category 1, and the games news archive displays posts from category 3.

    For general news archive I have

    <?php query_posts('cat=1', 'showposts=100');

    And for games news archive

    <?php query_posts('cat=3', 'showposts=100');

    (P.S. Changed the original code I posted here to a more simple one, both work the same way)

    Somehow the cat messes up the showposts=100, but I don't know how. Maybe the showposts=100 works only on posts that are not categorized?

  6. Michael
    Forum Moderator
    Posted 2 years ago #


    <?php query_posts('cat=1&posts_per_page=100');


    <?php query_posts( array( 'cat' => 1, 'posts_per_page' => 100 ) );


    using query_posts() is not recommended; in your case, consider to use 'pre_get_posts'

  7. Nuuzeli
    Posted 2 years ago #

    Thank you so much alchymyth! It worked like charm! :)

Topic Closed

This topic has been closed to new replies.

About this Topic