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' => __('← 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.
Now see image below of what I’m trying to achieve by using spans and brackets.
Can any help me modify my paginate query above to get these 2 things to work? Or is it not possible?
Thanks
3 Answers
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 ]";
}
?>