posts per page in admin for 'places'
This topic contains 13 replies, has 4 voices, and was last updated by Alex Rollin 7 years, 10 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
January 22, 2018 at 5:32 pm #413866
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 )January 23, 2018 at 8:55 am #413924Hello!
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”
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.
January 23, 2018 at 11:27 am #413956Hi 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
January 28, 2018 at 5:26 pm #414702Stiofan’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.phpfunction 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
January 29, 2018 at 12:17 am #414729Hello,
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.
January 29, 2018 at 10:25 pm #414877need 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 luckfunction 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’ );January 29, 2018 at 10:52 pm #414880Isn’t this a reading option under settings. “Blog pages show at most” …
January 29, 2018 at 10:57 pm #414881Does not work
January 29, 2018 at 11:15 pm #414884You are using Divi. This is inside the Divi options. In General Options there is the option for the number of posts. Here “Archives”.
January 29, 2018 at 11:27 pm #414885works!
January 29, 2018 at 11:29 pm #414886🙂
January 30, 2018 at 12:49 am #414911Thanks Dirk!
January 30, 2018 at 12:49 am #414912Thanks Dirk!
January 30, 2018 at 12:49 am #414913Thanks Dirk!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket