Created
September 21, 2022 08:46
-
-
Save cameronjonesweb/9d7b338bdf7a15ab622b5c27c24cec4c to your computer and use it in GitHub Desktop.
Bootstrapify `the_posts_pagination()`
This file contains hidden or 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
<?php | |
/** | |
* Update `the_posts_pagination()` markup for Bootstrap 4 styles | |
* | |
* Does this monstrosity work? Yes! Should you use it? Probably not. | |
* | |
* @param $markup string Original markup. | |
* @return string Updated markup. | |
*/ | |
function cameronjonesweb_bootstrapify_posts_pagination( $markup ) { | |
$markup = str_replace( 'div class="nav-links"', 'ul class="pagination"', $markup ); | |
$markup = str_replace( '<a', '<li class="page-item"><a', $markup ); | |
$markup = str_replace( '</a></li>', '</a></li>', $markup ); | |
$markup = str_replace( '<span', '<li class="page-item disabled"><a', $markup ); | |
$markup = str_replace( '</span', '</a></span', $markup ); | |
$markup = str_replace( 'page-numbers', 'page-link', $markup ); | |
return $markup; | |
} | |
/* USAGE */ | |
echo cameronjonesweb_bootstrapify_posts_pagination( get_the_posts_pagination( array( 'class' => '' ) ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment