WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] posts per page

[Resolved] posts per page

Viewing 6 replies - 1 through 6 (of 6 total)
  • Chris Olbekson

    @c3mdigital

    Level 12 Bug Squasher & Forum Moderator

    Posts per page can be changed globally by going to settings -> reading and entering 20 for the default how many posts per page to show.

    You can also use the pre_get_posts() filter if you are experienced with PHP and comfortable making code changes and additions to your site.

    trancebrothers

    @trancebrothers

    thanks a lot for the answer but I want change only in this page above!! not globally!!

    I’m not experienced with PHP, I need help in the code to change the problem!

    Chris Olbekson

    @c3mdigital

    Level 12 Bug Squasher & Forum Moderator

    You can add the following to your functions.php file. What this does is modify the posts per page setting on any monthly date archive.

    function trance_posts_per_page( $query ) {
        if (! is_main_query() || ! $query->is_month() )
            return;
    
        $query->set( 'posts_per_page', 20 );
    
    }
    
    add_action( 'pre_get_posts', 'trance_posts_per_page' );
    trancebrothers

    @trancebrothers

    ohhh finally!!!

    it results 😀

    thank you very much Chris!!

    You could use query_posts( 'posts_per_page=20' )

    See Function Reference/query posts

    OK, that was fashionably late 😉

    trancebrothers

    @trancebrothers

    sorry for the question, but where I put this code? in the function.php too?

    Anyway, the problem is solved 🙂

    thanks a lot guys! you really help me

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] posts per page’ is closed to new replies.