Created
May 26, 2016 00:05
-
-
Save BruceMcKinnon/b11d8ac662d2328605f37074a0426da3 to your computer and use it in GitHub Desktop.
Override WP Pagination in FoundationPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom Pagination. | |
function foundationpress_pagination() { | |
global $wp_query; | |
$big = 999999999; // This needs to be an unlikely integer | |
// For more options and info view the docs for paginate_links() | |
// http://codex.wordpress.org/Function_Reference/paginate_links | |
$paginate_links = paginate_links( array( | |
'base' => str_replace( $big, '%#%', html_entity_decode( get_pagenum_link( $big ) ) ), | |
'current' => max( 1, get_query_var( 'paged' ) ), | |
'total' => $wp_query->max_num_pages, | |
'mid_size' => 5, | |
'prev_next' => true, | |
'prev_text' => __( '<span class="fa fa-chevron-left"></span>', 'foundationpress' ), | |
'next_text' => __( '<span class="fa fa-chevron-right"></span>', 'foundationpress' ), | |
'type' => 'list', | |
) ); | |
$paginate_links = str_replace( "<ul class='page-numbers'>", "<ul class='pagination'>", $paginate_links ); | |
$paginate_links = str_replace( '<li><span class="page-numbers dots">', "<li><a href='#'>", $paginate_links ); | |
$paginate_links = str_replace( "<li><span class='page-numbers current'>", "<li class='current'><a href='#'>", $paginate_links ); | |
$paginate_links = str_replace( '</span>', '</a>', $paginate_links ); | |
$paginate_links = str_replace( "<li><a href='#'>…</a></li>", "<li><span class='dots'>…</span></li>", $paginate_links ); | |
$paginate_links = preg_replace( '/\s*page-numbers/', '', $paginate_links ); | |
// Display the pagination if more than one page is found. | |
if ( $paginate_links ) { | |
echo '<div class="row"><div class="small-12 small-centered columns">'; | |
echo $paginate_links; | |
echo '</div></div><!--// end .pagination -->'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment