• Resolved kgrundy60

    (@kgrundy60)


    I’ve been asked to look at a WordPress site where the category pages will only show 5 posts. I can’t seem to get any response from the author of the theme used and I can’t find any documentation to look through. I’m presuming the problem is with the php and I’ve found similar questions but the code for the solutions doesn’t seem to match with the code currently in the category.php file.

    The current code which I presume is the area of the problem is:

    <?php global $post; // required ?>
    <div class=”movecenter”>
    <?
    $args = array(‘category’ => 4); // include category 4
    $custom_posts = get_posts($args);
    foreach($custom_posts as $post) : setup_postdata($post);
    ?>

    Can anybody advise what I need to add/amend to get it to pick up all the posts in the particular category? If I change the get_posts($args) to query_posts($args) then this shows more post but these are not limited to the individual category.

    Any help would be greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • if you don’t specifically specifiy the number of posts pser page, then it will get taken from the ‘settings – reading’ in the dashboard;

    change this line:

    $args = array('category' => 4); // include category 4

    to:

    $args = array('category' => 4, 'posts_per_page' => -1); // include category 4 and show all posts per page

    Thread Starter kgrundy60

    (@kgrundy60)

    Excellent! Thanks a lot, that’s sorted it. I’m still new to php and there seems to be so many different ways of achieving the same end result. I’ll get to grips with it eventually (I hope) ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Category page only showing 5 posts’ is closed to new replies.