• Hello Eric,

    thanks for your great plugin. This was the last one I was looking for to move from movable type to wordpress… Now it’s done.

    One thing I missed. The possibility to display page numbers during pagination. Here is a short solution I´ve created for doing this. It works fine on my site. Here’s an example where I’ve used your plugin, posting a lot of my toons: Cartoons.

    I’ve made small modifications in lib/page_posts.php. Perhaps the next release will include this.

    Roger

    protected function paginate_links( $posts ){
    		global $wp_query;
    		$page_url = home_url( '/' . $wp_query->post->post_name . '/' );
    		$page = isset( $_GET['page'] ) ? $_GET['page'] : 1;
                    $total_pages = $posts->max_num_pages;
                    $per_page = $posts->query_vars['posts_per_page'];
    
                    $curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0) ? $posts->query_vars['paged'] : 1;
                    $prev = ( $curr_page && $curr_page > 1 ) ? '<a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a>' : '';
    
                    $middle = "";                   // string for the pages with numbers
                    $page_number = 0;               // start with page 1
                    while ( $page_number < $total_pages ):
                            $page_number  = $page_number + 1;                       // next page from pagination
                            $curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0) ? $posts->query_vars['paged'] : 1;
                            If ($curr_page == $page_number) {
                                    $middle = $middle . " {$page_number}";          // this is the current page
                            } else {
    //                                $middle = $middle . " <a href="{$page_url}?page={$page_number}">{$page_number}</a>";    // Form:../?page=1,2,3,...
                                    $middle = $middle . " <a href="{$page_url}{$page_number}">{$page_number}</a>";            // with Permalink:../1,2,3,..
                                   }
                    endwhile;
                    $next = ( $curr_page && $curr_page < $total_pages ) ? ' <a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a>' : '';
                    $new_output = '<center><p>' . $prev . $middle . $next. '</p></center>';
    
                    return $new_output;
    	}

    These forums do not support commercial products. Only the free plugins downloaded from http://wordpress.org/plugins/. Please contact the plugin’s vendor directly with any questions about commercial products.

    http://wordpress.org/plugins/posts-in-page/

The topic ‘Solution for pagination with page numbers’ is closed to new replies.