Forums › Forums › Search & Filter Pro › Setup pagination for archive page
Tagged: pagination
- This topic has 5 replies, 2 voices, and was last updated 8 years, 6 months ago by Anonymous.
-
Anonymous(Private) April 15, 2016 at 10:49 am #42833
Hi,
I’m using the Filter Pro plugin for a custom post with a custom archive page using the default loop as it should. Everything is fine except for one thing; pagination on the archive page.
I’m using the following snippet in my functions.php file to setup the pagination for the CPT:
function set_posts_per_page_for_cpt( $query ) { if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'portfolio_item' ) ) { $query->set( 'posts_per_page', '9' ); } } add_action( 'pre_get_posts', 'set_posts_per_page_for_cpt' );
This does show the correct amount of custom posts on the archive page and shows the pagination as well. However when using the pagination links to show the next page of post it just shows the same posts as shown on the first page. It reloads the page with AJAX, alters the url ( …/?sf_paged=2 ) but doesn’t show the next bunch of posts. Is there a way to fix?
Ross Moderator(Private) April 15, 2016 at 10:55 am #42835Hi Niels
S&F has its own setting for post per page in the UI, why not remove this code and use the S&F setting to see if it works?
To be honest, I actually see no problem with this code specifically but its worth testing out.
Thanks
-
AuthorPosts