• Resolved benoitf92

    (@benoitf92)


    Hi,

    I’m doing a template page to display custom post type content.
    I have well display one and 5 post on thearchive page.

    I’m looking to add paginaton system.

    I have that:

    $total = $the_query->max_num_pages;
    if ( $total > 1 )  {
    
    if ( !$current_page = get_query_var('page') )
    	$current_page = 1;
    
    // structure of "format" depends on whether we're using pretty permalinks
    $format = '%#%';
    	
    echo paginate_links(array(
    	'base'     => get_pagenum_link(0) . '%#%',
    	'format'   => $format,
    	'current'  => $current_page,
    	'total'    => $total,
    	'mid_size' => 5,
    	'add_args' => true
    	));

    For first page it is fine I got URL https://mysite.com/mypagetitle/
    For the second page also https://mysite.com/mypagetitle/2/
    Since I’m on second or other not https://mysite.com/mypagetitle/2/3 or https://mysite.com/mypagetitle/20/5

    How can I correct url on pagination link ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi!

    What happens if you simply use paginate_links()?

    If that works then an argument you are passing could be causing that.

    Thread Starter benoitf92

    (@benoitf92)

    Hi

    I have tryied it but I gor error from paginate_links missing parameters or no paginate link.

    Thread Starter benoitf92

    (@benoitf92)

    Hi,

    I have https://mysite.com/mypagetitle/20/5 or similar url

    I do not understand why I have the current page number and the next one in the link. To have a good page I only need the next page number.

    I think, I have one thing wrong:

    $format = '%#%';
    	
    echo paginate_links(array(
    	'base'     => get_pagenum_link(0) . '%#%',
    	'format'   => $format,
    	'current'  => $current_page,
    	'total'    => $total,
    	'mid_size' => 5,
    	'add_args' => true
    	));
    Thread Starter benoitf92

    (@benoitf92)

    Hi

    I solve it

    I have replace the wrong url inside by

    echo paginate_links(array(
    'base'     => get_permalink() .'%#%',
    'format'   => $format,
    'current'  => $paged,
    'total'    => $total,
    'end_size' => 2,
    'mid_size' => 4,
    'add_args' => true
    ));
    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Glad to see you were able to get it solved.

    From what I can tell it was the wrong base that was being passed. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wrong Pagination link’ is closed to new replies.