Forums Forums Search & Filter Pro Setup pagination for archive page

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #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
    #42835

    Hi 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

    Anonymous
    #42836

    Hi Ross,

    Is that the ‘Results per page’ setting on the General settings tab? I removed the snippet and used this setting but the problem remains unfortunately.

    Thought that setting was to limit the amount of results after applying the filter(s).

    Anonymous
    #42846
    This reply has been marked as private.
    Ross Moderator
    #42945
    This reply has been marked as private.
    Anonymous
    #43046

    Hmz that’s odd, I’m 99% sure that it didn’t work before but now it works as it should indeed. I’ll save your snippet in case I might need it later on. Thanks!

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