add spans and characters into paginate_links

I am using paginate_links on my custom page query.

What I have already works sweet and this is the code I have so far…

<?php
    global $wp_query;

    $big = 999999999; // need an unlikely integer

    echo paginate_links( array(
        'base'      => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
        'format'    => '?paged=%#%',
        'current'   => max( 1, get_query_var('paged') ),
        'total'     => $wp_query->max_num_pages,
        'prev_text' => __('&#8592; Previous'),
        'next_text' => __('Next &#8594;')
    ));
?>

Though I really need to be it a bit more different, but can’t find any documentation on how to bend the rules with it.

Question 1
I need the prev_text and next_text to be translatable. I have been adding my theme text domain for localization through-out my theme. And on generic text strings, I have been using this <?php _e('Latest Dowloads','mythemetextdomain'); ?>. How can I add my theme text domain into the prev_text and next_text string.

Question 2
How can I add <span class="bracket">[</span> and <span class="bracket">]</span> between each of my paginated page numbers?

Please see image below of what my current pagination is looking like.

enter image description here

Now see image below of what I’m trying to achieve by using spans and brackets.

enter image description here

Can any help me modify my paginate query above to get these 2 things to work? Or is it not possible?

Thanks

3 Answers
3

The function paginate_links() can return “plain”, “list” and “array” (http://codex.wordpress.org/Function_Reference/paginate_links). Just define the type as array then you’ll be to display it as you want:

<?php
    global $wp_query;

    $big = 999999999; // need an unlikely integer

    $paginate_links = paginate_links( array(
        'base'      => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
        'format'    => '?paged=%#%',
        'current'   => max( 1, get_query_var('paged') ),
        'total'     => $wp_query->max_num_pages,
        'prev_text' => __('&#8592; Previous'),
        'next_text' => __('Next &#8594;'),
        'type'      => 'array'
    ));

    foreach ( $paginate_links as $pgl ) {
        echo "[ $pgl ]";
    }
?>

Leave a Comment