Simple question – Places per page adjustment

This topic contains 5 replies, has 2 voices, and was last updated by  Paolo 7 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #214888

    Jason Emanuelson
    Full Member
    Post count: 71

    Sorry for what is probably a stupid question.

    I might be totally blind, but I cannot find the place to specify how many places are shown on a given page.

    #215318

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    that is a WordPress option and you can find it in Settings >> Reading >> Blog pages show at most.

    Thanks.

    #215378

    Jason Emanuelson
    Full Member
    Post count: 71

    I can understand using a global value like this for a site that is only a directory, but it would be really nice to be able to set this on a post-type basis, or even a category level. Also wish there was a way to make the display dynamic to the number of results. It would help to make a directory look less formulaic, especially when you have good photography.

    #215412

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    you can easily overwrite that via functions.php.

    Example:

    
    
    
    function set_posts_per_page_for_cpt( $query ) {
      if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'gd_place' ) ) {
        $query->set( 'posts_per_page', '20' );
      }
    }
    add_action( 'pre_get_posts', 'set_posts_per_page_for_cpt' );

    I haven’t tested this, so use with caution.

    otherwise you could try a plugin like this: https://wordpress.org/plugins/custom-posts-per-page/

    Let us know how you went,

    Thanks

    #215433

    Jason Emanuelson
    Full Member
    Post count: 71

    I will definitely try this and get back to you. Thank you!

    #215470

    Paolo
    Site Admin
    Post count: 31206

    You are welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket