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…

Read More
<?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' => __('← Previous'),
        'next_text' => __('Next →')
    ));
?>

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

Related posts

Leave a Reply

3 comments

  1. 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' => __('← Previous'),
            'next_text' => __('Next →'),
            'type'      => 'array'
        ));
    
        foreach ( $paginate_links as $pgl ) {
            echo "[ $pgl ]";
        }
    ?>
    
  2. For the brackets, I’d try to do:

    .pagenumber:before { content:'['; }
    .pagenumber:after { content:']'; }
    

    And you can also use margins, paddings, positioning, etc. to get it exactly how you want it.

  3. Question 1: Use __ (double underscore) instead of _e.

    Question 2: There may be a filter or hook available to do this but you can also use CSS to generate content for the page_number class.