This topic has 3 replies, 2 voices, and was last updated 9 years by steeportaladmin.

  • Author
  • #30041
     steeportaladmin
    Participant

    Hi, Is there anyway I could configure numeric pages displayed on Kleo?

    Currently I have about 180 pages – but pagination displayed on 1st page display is quite weird (only shows next page 2 and last page 180). Thus from first page, it’ll be difficult to go to page 5. I tried to solve it using WP-Paginate plugin but it does not seem to work. Any idea?

    Screenshot

    #30042
     steeportaladmin
    Participant

    Screenshot

    Attachments:
    You must be logged in to view attached files.
    #30997
     Catalin
    Moderator

    Hello,

    Add this to your functions.php code:

    COPY CODE
    
    
    function kleo_pagination( $pages = '', $echo = true ) {
    
        $output = '';
        if( $pages == '' )
        {
            global $wp_query;
            $pages = $wp_query->max_num_pages;
            if( ! $pages )
            {
                $pages = 1;
            }
        }
    
    	// Don't print empty markup if there's only one page.
    	if ( $pages < 2 ) {
    		return;
    	}
    
    	$paged        = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
    	$pagenum_link = html_entity_decode( get_pagenum_link() );
    	$query_args   = array();
    	$url_parts    = explode( '?', $pagenum_link );
    
    	if ( isset( $url_parts[1] ) ) {
    		wp_parse_str( $url_parts[1], $query_args );
    	}
    
    	$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
    	$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
    
    	$format  = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
    	$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
    
    	// Set up paginated links.
    	$links = paginate_links( array(
    		'base'     => $pagenum_link,
    		'format'   => $format,
    		'total'    => $pages,
    		'current'  => $paged,
    		'mid_size' => 1,
    		'add_args' => array_map( 'urlencode', $query_args ),
    		'prev_text' => __( '«', 'kleo_framework' ),
    		'next_text' => __( '»', 'kleo_framework' ),
    		'type' => 'array'
    	) );
    
    	if ( $links ) {
            $output .= '<nav class="pagination-nav clear" role="navigation">'
                . '<ul class="pagination">';
    
            foreach ($links as $link) {
                $output .= '<li>' . $link . '</li>';
            }
    
            $output .= '</ul>'
                . '</nav><!-- .navigation -->';
        }
    
        if ($echo ) {
            echo $output;
        }
        else {
            return $output;
        }
    
    

    and increase this line value:

    COPY CODE
    
    
    'mid_size' => 1,
    
    

    to a higher number.

    let me know if this works.

    Thank you,
    Catalin

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #31241
     steeportaladmin
    Participant

    Works Awesome! Thanks lots!!!!

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

The topic ‘How to configure numeric pagination displayed’ is closed to new replies.

Log in with your credentials

Forgot your details?