0

Based on: http://codex.wordpress.org/Function_Reference/paginate_links how to make these links show as 01, 02, 03... rather than the normal single digit?

thanks so much

0

Try switching the pagination type to array. That way you can use each link in a loop and add what you need to them:

Using the example from the codex:

global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages,
        'type' => array
) );

foreach ( $paginate_links as $link ) {
        echo sprintf("%02s", $link);
    }

The php sprintf function will add a leading zero.

|improve this answer|||||
  • This did not work for me. – Eric K Feb 14 at 21:35
0

The approved answer did not work for me. Taking a suggestion from Edit format of Paginate_Links(), I used the following code:

PLACE IN FUNCTIONS.PHP

function give_numbers_leading_zero( $number ) {
    return sprintf("%02s", $number);
}

PAGINATION CODE

add_filter( 'number_format_i18n', 'give_numbers_leading_zero' );

$paginate_links = paginate_links( array(
    'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
    'total'        => $query->max_num_pages,
    'current'      => max( 1, get_query_var( 'paged' ) ),
    'format'       => '?paged=%#%',
    'type'         => 'array'
) );

remove_filter( 'number_format_i18n', 'give_numbers_leading_zero' );

if($paginate_links){ 
    foreach ( $paginate_links as $link ) {
        echo $link;
    }
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.