WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Override Posts Per Page (3 posts)

  1. Daven
    Member
    Posted 5 years ago #

    I'm trying to create some custom category archive pages for my site, and one thing that is happeneing that I don't want happening is that they are obeying the default "Posts per page" that I have set at 10.

    I want only 10 posts displaying on my front page (index.php) and on these new category-xx.php pages I want just a list of links, say 40 of them per page before it goes to another page.

    Is there a code snippet to do this, or am I going to have to live with having only 10 links on the category-xx pages?

  2. Daven
    Member
    Posted 5 years ago #

    Nevermind, found it. Went hunting on Google. This is what I found:

    * Either edit your category.php file, or if it doesn’t exist, copy your index.php file to category.php.
    * look for this line:
    < ?php get_header(); ?>
    and change it to the following:
    < ?php get_header(); query_posts( 'posts_per_page=-1&cat=' . $cat ) ?>
    * That’s all, your finished. The -1 in posts_per_page lets WordPress know you want all posts to be shown and it overrides the setting in your options.

    Think I'll go try it out.

  3. Daven
    Member
    Posted 5 years ago #

    Worked like a dream. Replaced it at the top of the page, and now I have all the links on one page that I can direct people to in my site.

    Thanks WordPress! LOL

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.