Edit format of Paginate_Links()

I’m using paginate_links to paginate the results of a loop.

I want to style the pagination using dots instead of numbers, but I’m not sure how to go about doing this.

Read More

I could try to play around with the css but I would prefer a clean method.

example.

<-                 o o o                ->

currently.

<-                 1 2 3                ->

This is currently how I am outputting my links.

<?php

$big = 999999999;

$paginate_links = paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $the_query->max_num_pages,
    'prev_text'    => __('<div class="prev pull-left"><i class="icon-arrow_thin_left"></i></div>'),
    'next_text'    => __('<div class="next pull-right"><i class="icon-arrow_thin_right"></i></div>'),
    'type' => 'array',
    'n_display' => 'test'
) );

foreach ( $paginate_links as $pgl ) {
    echo "$pgl";
}

?>

Looking at the core paginate_links() function in WordPress is there anyway I can modify the output of $n_display before or after.

Related posts

1 comment

  1. There is no clean way to do this (that I notice from quick look at rather messy code of it), but $n_display is passed though formatting number_format_i18n() function which does have a filter.

    So you could try something like:

    function make_number_into_dot( $number ) {
        return 'o';
    }
    
    add_filter( 'number_format_i18n', 'make_number_into_dot' );
    
    // your pagination handling here
    
    remove_filter( 'number_format_i18n', 'make_number_into_dot' );
    

Comments are closed.