posts per page in admin for 'places'

This topic contains 13 replies, has 4 voices, and was last updated by  Alex Rollin 7 years, 1 month ago.

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

Open Support Ticket
  • Author
    Posts
  • #413866

    Henry Wythe
    Expired Member
    Post count: 40

    I have many thousands of listings and to manage them properly I neeed to set the number of posts per page very high in the admin panel.

    The question is: How do I chanege the divisor used in ‘page x of y’

    Background:

    This works fine to set the number per page:

    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’, ‘100’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘set_posts_per_page_for_cpt’ );

    The problem is, the “page x of y” still computes the total number of pages based on some system default (20)

    FYI:
    Neither the total number or the page x of y is affected by the value in the settings page (settings/reading : Blog pages show at most )

    #413924

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    We have a couple other listing page snippets here that you can take a look at here under the subtitle:

    “Listing Page – Add Advanced Pagination and Show More Listings”

    https://wpgeodirectory.com/docs/faqs/what-are-some-examples-of-changes-that-a-developer-can-make-to-the-listings-page/

    There are a couple “Read More”links there that you can follow for a couple more.

    Please be patient while we confer to see if there is an easy solution for this.

    #413956

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Henry,

    When in the wp-admin places view simply click “Screen options” at the top right and then set the “Number of items per page”.

    Thanks,

    Stiofan

    #414702

    Henry Wythe
    Expired Member
    Post count: 40

    Stiofan’s advice is correct for the admin page.
    Then I tried changing the front end, using the link that Alex posted. First I used the Settings/Reading/Max#BlogPosts
    No luck
    Then I tried adding this to functions.php

    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’ );

    Still no luck.

    Thanks for taking a look at this

    #414729

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    Can you clarify the issue?

    Set the number of posts in a page on the front end
    for admins only
    for gd_places only?

    Is that right?

    I will flag your request for the developers.

    #414877

    Henry Wythe
    Expired Member
    Post count: 40

    need to set the number of posts seen on the front end for ALL users.
    Right now it’s stuck on 5 listings per page – way too small.

    http://directory.creates.today/places/

    I don’t mind patching functions.php but can’t figure it out.

    My last code snippet was an attempt to set it for ‘not admin’ users
    This snippet tries to do it for ALL users, but no luck

    function set_posts_per_page_for_cpt( $query ) {
    if ( $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’ );

    #414880

    Dirk
    Full Member
    Post count: 390

    Isn’t this a reading option under settings. “Blog pages show at most” …

    #414881

    Henry Wythe
    Expired Member
    Post count: 40

    Does not work

    #414884

    Dirk
    Full Member
    Post count: 390

    You are using Divi. This is inside the Divi options. In General Options there is the option for the number of posts. Here “Archives”.

    #414885

    Henry Wythe
    Expired Member
    Post count: 40

    works!

    #414886

    Dirk
    Full Member
    Post count: 390

    🙂

    #414911

    Alex Rollin
    Moderator
    Post count: 27815

    Thanks Dirk!

    #414912

    Alex Rollin
    Moderator
    Post count: 27815

    Thanks Dirk!

    #414913

    Alex Rollin
    Moderator
    Post count: 27815

    Thanks Dirk!

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount