Skip to content

Instantly share code, notes, and snippets.

@cjmosure
Last active June 12, 2019 10:11
Show Gist options
  • Save cjmosure/d542f5f5d468855cb52effab5e9e2c95 to your computer and use it in GitHub Desktop.
Save cjmosure/d542f5f5d468855cb52effab5e9e2c95 to your computer and use it in GitHub Desktop.
WP-PageNavi - Bootstrap 4
<?php
/**
* Clean up pagination
*/
add_filter( 'wp_pagenavi', __NAMESPACE__ . '\\gc_pagination', 10, 2 );
function gc_pagination($html) {
$out = '';
$out = str_replace('<div','',$html);
$out = str_replace('class=\'wp-pagenavi\'>','',$out);
$out = str_replace('<a','<li class="page-item"><a class="page-link"',$out);
$out = str_replace('</a>','</a></li>',$out);
$out = str_replace('<span class=\'current\'','<li class="page-item active"><span class="page-link current"',$out);
$out = str_replace('<span class=\'pages\'','<li class="page-item"><span class="page-link pages"',$out);
$out = str_replace('<span class=\'extend\'','<li class="page-item"><span class="page-link extend"',$out);
$out = str_replace('</span>','</span></li>',$out);
$out = str_replace('</div>','',$out);
return '<ul class="pagination">'.$out.'</ul>';
}
?>
@soufianesabiri
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment