• hi, i have a big problem with my pagination when passing additional url parameters. without parameters, the generated urls look like this and working fine: http://myurl.de/experten/page/2/

    here is the code of pagination function:

    function paginate($first=1,$last=1,$middle=5,$baseURL=false,$wp_query=false ) {
           if(!$baseURL) $baseURL= get_bloginfo('url');
           if(!$wp_query)global $wp_query;
           $page = $wp_query->query_vars["paged"];
           if ( !$page ) $page = 1;
           $qs = $_SERVER["QUERY_STRING"] ? "?".$_SERVER["QUERY_STRING"] : "";
           if ( $wp_query->found_posts > $wp_query->query_vars["posts_per_page"] ) {// Only necessary if there's more posts than posts-per-page
                   echo '<ul class="page-numbers">';
                   if ( $page > 1 ) { // Previous link?
                           echo '<li class="previous"><a href="'.$baseURL.(($page==2)?('page/'.($page-1).'/'):'').$qs.'">« Previous</a></li>';
                   }
                   $dots=false;
                   for ( $i=1; $i <= $wp_query->max_num_pages; $i++ ){ // Loop through pages
                           if($i<=$first || $i<=$middle && $page<$middle || $i>$wp_query->max_num_pages-$last || $i>$wp_query->max_num_pages-$middle && $page>$wp_query->max_num_pages-$middle+1 || $i>$page-ceil($middle/2) && $i<=$page+floor($middle/2)){
                                   if ( $i == $page ) { // Current page or linked page?
                                           echo '<li class="active">'.$i.'</li>';
                                   } else {
                                           echo '<li><a href="'.$baseURL.(($i!=1)?('page/'.$i.'/'):'').$qs.'">'.$i.'</a></li>';
                                   }
                                   $dots=false;
                           }elseif(!$dots){
                                   echo '<li class="dots">...</li>';
                                   $dots=true;
                           }
                   }
                   if ( $page < $wp_query->max_num_pages ) { // Next link?
                           echo '<li><a href="'.$baseURL.'page/'.($page+1).'/'.$qs.'">Next »</a></li>';
                   }
                   echo '</ul>';
           }
    }

    the generated urls of pagination look like this: http://myurl.de/experten/page/2/?bundesland=31&plz=&behandlung-frau=&s=&behandlung-mann=&post_type=experten

    as you can see, some parameters are empty, but since the search works well with this, that shouldn’t be a problem for pagination.

    could anyone tell me, how he solved the pagination and parameter problem or how he handles mutltiple search parameters? i get my parameters this way:

    $bundesland_query = filter_input(INPUT_GET, 'bundesland', FILTER_SANITIZE_STRING);
    $plz_query = filter_input(INPUT_GET, 'plz', FILTER_SANITIZE_NUMBER_INT);
    $behandlung_frau_query = filter_input(INPUT_GET, 'behandlung-frau', FILTER_SANITIZE_STRING);
    $behandlung_mann_query = filter_input(INPUT_GET, 'behandlung-mann', FILTER_SANITIZE_STRING);
    $arzt_query = filter_input(INPUT_GET, 's', FILTER_SANITIZE_STRING);
    $bundesland_name = get_term_by('id', $bundesland_query, 'bundesland');
    $behandlung_frau = get_term_by('id', $behandlung_frau_query, 'frau');
    $behandlung_mann = get_term_by('id', $behandlung_mann_query, 'mann');

    thank you in advance!

The topic ‘numeric pagination doesnt work with parameters’ is closed to new replies.