Forums Forums Search & Filter Pro Pagination not working for custom results

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #212366

    Hi there! I am setting up a search form to filter a custom post type that I am displaying using Beaver Builders posts module on this page: https://staging-universallifetools.kinsta.cloud/our-teachers

    I am using a pre_get_posts to hook up the search and filter pro integration and the filtering itself works great, except the pagination is not working.

    For example, when I go to https://staging-universallifetools.kinsta.cloud/our-teachers/?sf_paged=2 – it is still displaying page one of the results.

    I am using the Custom display results method and have specified https://staging-universallifetools.kinsta.cloud/our-teachers as the template

    Ajax container has been specified as #prac-grid-teacher and Ajax pagination is .fl-builder-pagination a

    I am hoping you can point me in the direction of where I am going wrong.

    Trevor
    #212392
    This reply has been marked as private.
    Anonymous
    #212512

    Hi Trevor – I am using the below code. Happy to catchup via Skype but I am in Australia GMT +10 so not sure what time zone you are in?

    add_filter(“pre_get_posts”, “modify_bb_query”);

    function modify_bb_query($query){

    if(!isset($query->query_vars[‘fl_builder_loop’])){
    return $query;
    }

    //if is page “our-teachers” and this is a fl_builder_loop
    if((is_page(“our-teachers”)) && ($query->query_vars[‘fl_builder_loop’] == true)){
    //then attach S&F to the query
    $query->set(‘search_filter_id’, 26869);

    $taxquery = array(
    array(
    ‘taxonomy’ => ‘teacher_status’,
    ‘field’ => ‘slug’,
    ‘terms’ => array( ‘teacher’ ),
    )
    );
    $query->set( ‘tax_query’, $taxquery );

    }
    }

    Anonymous
    #212514

    I have just taken this code out and it still does not work. If I take the shortcode for the search and filter pro searh out, then the pagination works again, so I am not sure what is happening. Happy to share login details if that would help as it is only a staging site

    Trevor
    #212521

    Rather than using pre_get_posts, I think you should be using our Edit Query Arguments filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    I am in the UK, but often work odd hours. As you can see, I am here right now at 6AM on a Saturday!

    pre_get_posts used with our filter has the potential to cause problems.

    Anonymous
    #212527

    To be honest I am not sure how to create that function – it’s a bit beyond my abilities.

    I tried this, but it made the search form stop working.
    function filter_function_name( $query_args, $sfid ) {

    //if search form ID = 225, the do something with this query
    if($sfid==26869)
    {
    //modify $query_args here before returning it

    $query_args[‘post_type’] = array( ‘practitioners’ );
    }

    return $query_args;
    }
    add_filter( ‘sf_edit_query_args’, ‘filter_function_name’, 20, 2 );

    Just to simply matters, I have removed all the functions.php code altogether for the time being. As you will see on the page, the pagination does not seem to work with the search form on the page. When I put in a manual pagination link of https://staging-universallifetools.kinsta.cloud/our-teachers/page/2 it works, but the actual pagination buttons do not seem to do anything, just refresh the page.

    Trevor
    #212638
    This reply has been marked as private.
Viewing 7 posts - 1 through 7 (of 7 total)